Skip to content

Instantly share code, notes, and snippets.

@seancribbs
Created February 13, 2012 14:00
Show Gist options
  • Save seancribbs/1817132 to your computer and use it in GitHub Desktop.
Save seancribbs/1817132 to your computer and use it in GitHub Desktop.
diff --git a/lib/ripple/associations/many_embedded_proxy.rb b/lib/ripple/associations/many_embedded_proxy.rb
index 6fd5c93..287a6cb 100644
--- a/lib/ripple/associations/many_embedded_proxy.rb
+++ b/lib/ripple/associations/many_embedded_proxy.rb
@@ -10,9 +10,10 @@ module Ripple
def <<(docs)
load_target
- @reflection.verify_type!(Array(docs), @owner)
+ docs = [ docs ] unless Array === docs
+ @reflection.verify_type!(docs, @owner)
assign_references(docs)
- @target += Array(docs)
+ @target += docs
self
end
diff --git a/lib/ripple/attribute_methods.rb b/lib/ripple/attribute_methods.rb
index de73fdb..02f0531 100644
--- a/lib/ripple/attribute_methods.rb
+++ b/lib/ripple/attribute_methods.rb
@@ -43,11 +43,14 @@ module Ripple
# 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
+ # @return [Hash] all defined attributes, by key
def attributes
raw_attributes.reject { |k, v| !respond_to?(k) }
end
+ # A copy of all attributes in the document, including ones that
+ # are not defined in properties.
+ # @return [Hash] all attributes, including undefined ones, by key
def raw_attributes
self.class.properties.values.inject(@attributes.with_indifferent_access) do |hash, prop|
hash[prop.key] = attribute(prop.key)
@@ -84,22 +87,23 @@ module Ripple
# @private
def initialize(attrs={})
super()
+ self.class.define_attribute_methods
@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
- super
- end
+ # def method_missing(method, *args, &block)
+ # self.class.define_attribute_methods
+ # super
+ # end
- # @private
- def respond_to?(*args)
- self.class.define_attribute_methods
- super
- end
+ # # @private
+ # def respond_to?(*args)
+ # self.class.define_attribute_methods
+ # super
+ # end
protected
# @private
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment