lib/ripple/document/attribute_methods.rb in ripple-0.6.1 vs lib/ripple/document/attribute_methods.rb in ripple-0.7.0

- old
+ new

@@ -26,11 +26,10 @@ autoload :Write autoload :Query autoload :Dirty included do - attr_accessor :key include Read include Write include Query include Dirty end @@ -48,10 +47,12 @@ super(properties.keys) end end module InstanceMethods + attr_accessor :key + # A copy of the values of all attributes in the Document. The result # is not memoized, so use sparingly. This does not include associated objects, # nor embedded documents. # @return [Hash] all document attributes, by key def attributes @@ -64,22 +65,28 @@ # Mass assign the document's attributes. # @param [Hash] attrs the attributes to assign def attributes=(attrs) raise ArgumentError, t('attribute_hash') unless Hash === attrs attrs.each do |k,v| + next if k.to_sym == :key if respond_to?("#{k}=") __send__("#{k}=",v) else __send__(:attribute=,k,v) end end end + + def key=(value) + @key = value.to_s + end # @private def initialize(attrs={}) super() @attributes = attributes_from_property_defaults self.attributes = attrs + yield self if block_given? end # @private def method_missing(method, *args, &block) self.class.define_attribute_methods