- Moving
Format.binding_for_definition
toFormat#{format}_binding_for_definition
, making it an instance method in its own “namespace”. This allows mixing in multiple representer engines into a user’s representer module.
- Extracted
HashRepresenter
which operates on hash structures. This allows you to “parse” form data, e.g. as in Rails’params
hash. Internally, this is used by JSON and partly by YAML.
- Add support for YAML.
- ObjectBinding no longer tries to extend nil values when rendering and
:render_nil
is set. - In XML you can now use
:wrap
to define an additional container tag around properties and collections.
- Using virtus for coercion now works in both classes and modules. Thanks to @solnic for a great collaboration. Open-source rocks!
- Added
XML::AttributeHash
to store hash key-value pairs in attributes instead of dedicated tags. JSON::Hash
,XML::Hash
andXML::AttributeHash
now respect:exclude
and:include
when parsing and rendering.
- Deprecated
:represent_nil
favor of:render_nil
. - API change: if a property is missing in an incoming document and there is no default set it is completely ignored and not set in the represented object.
- Deprecated
:except
in favor of:exclude
. - A property with
false
value will now be included in the rendered representation. Same applies to parsing,false
values will now be included. That particularly means properties that used to be unset (i.e.nil
) after parsing might befalse
now. - You can include
nil
values now in your representations since#property
respects:represent_nil => true
.
- Added
:if
option toproperty
.
- Definitions are now properly cloned when
Config
is cloned.
- representable_attrs is now cloned when a representer module is included in an inheriting representer.
- Introduced `#compile_fragment` and friends to make it simpler overriding parsing and rendering steps.
- Allow `Module.hash` to be called without arguments as this seems to be required in Padrino.
- When a representer module is extended we no longer set the
@representable_attrs
ivar directly but use a setter. This makes it work with mongoid and fixes trailblazer/roar#10.
- Added `JSON::Collection` to have plain list representations. And `JSON::Hash` for hashes.
- Added the `hash` class method to XML and JSON to represent hashes.
- Defining `:extend` only on a property now works for rendering. If you try parsing without a `:class` there’ll be an exception, though.
- Allow passing a list of modules to :extend, like
:extend => [Ingredient, IngredientRepresenter]
.
- 1.0.0 release! Party time!
- Removed property :
name from @XML
in favor of:attribute => true
.
- We no longer create accessors in
Representable.property
– you have to do this yourself usingattr_accessors
.
:as
is now:class
.
- Representer modules can now be injected into objects using
#extend
. - The
:extend
option allows setting a representer module for a typed property. This will extend the contained object at runtime roughly following the DCI pattern. - Renamed
#representable_property
and#representable_collection
to#property
and#collection
as we don’t have to fear namespace collisions in modules.
- Added
representable_property :default => ...
option which is considered for both serialization and deserialization. The default is applied when the value isnil
. Note that an empty string ain’tnil
. representable_attrs
are now pushed to instance level as soon as possible.
- Added
representable_property :accessors => false
option to suppress adding accessors. Representable.representation_wrap
is no longer inherited.- Representers can now be defined in modules. They inherit to including modules.
- The block in
to_*
andfrom_*
now yields the symbolized property name. If you need the binding/definition you gotta get it yourself. - Runs with Ruby 1.8 and 1.9.
- Wrapping can now be set through
Representable.representation_wrap=
. Possible values are: false
: No wrapping. In XML context, this is undefined behaviour. Default in JSON.String
: Wrap with provided string.true
: compute wrapper from class name.
- Removed the
:as => [..]
syntax in favor of:array => true
.
- Arguments and block now successfully forwarded in
#from_*
.
- Extracted common serialization into
Representable#create_representation_with
and deserialization into#update_properties_from
. - Both serialization and deserialization now accept a block to make them skip elements while iterating the property definitions.
- Removed the :tag option in favor of :from. The Definition#from method is now authorative for all name mappings.
- Removed the active_support and i18n dependency.