lib/recurly/resource.rb in recurly-2.0.8 vs lib/recurly/resource.rb in recurly-2.0.9

- old
+ new

@@ -203,11 +203,11 @@ # a.name_changed? # => true # a.name_was # => nil # a.name_change # => [nil, "Stephen"] def define_attribute_methods attribute_names @attribute_names = attribute_names.map! { |m| m.to_s }.sort!.freeze - remove_const :AttributeMethods if const_defined? :AttributeMethods + remove_const :AttributeMethods if constants.include? :AttributeMethods include const_set :AttributeMethods, Module.new { attribute_names.each do |name| define_method(name) { self[name] } # Get. define_method("#{name}=") { |value| self[name] = value } # Set. define_method("#{name}?") { !!self[name] } # Present. @@ -420,11 +420,11 @@ end # @return [Hash] A list of association names for the current class. def associations @associations ||= begin - unless const_defined? :Associations + unless constants.include? :Associations include const_set :Associations, Module.new end { :has_many => [], :has_one => [], :belongs_to => [] } end @@ -504,14 +504,15 @@ # @return [:has_many, :has_one, :belongs_to, nil] An association type. def reflect_on_association name a = associations.find { |k, v| v.include? name.to_s } and a.first end - def embedded! - private_class_method(*%w( - new create create! paginate find_each scoped where all - )) + def embedded! root_index = false private :initialize + private_class_method(*%w(new create create!)) + unless root_index + private_class_method(*%w(all find_each first paginate scoped where)) + end end end # @return [Hash] The raw hash of record attributes. attr_reader :attributes