lib/representable.rb in representable-1.1.0 vs lib/representable.rb in representable-1.1.1
- old
+ new
@@ -23,10 +23,12 @@
# property :name
# end
#
# hero.extend(HeroRepresenter).to_json
module Representable
+ attr_writer :representable_attrs
+
def self.included(base)
base.class_eval do
extend ClassMethods
extend ClassMethods::Declarations
extend ClassMethods::Accessors
@@ -35,13 +37,10 @@
base.representable_attrs.push(*representable_attrs) # "inherit".
end
# Copies the representable_attrs to the extended object.
def self.extended(object)
- attrs = representable_attrs
- object.instance_eval do
- @representable_attrs = attrs
- end
+ object.representable_attrs=(representable_attrs)
end
end
end
# Reads values from +doc+ and sets properties accordingly.