Module: MassiveRecord::ORM::AttributeMethods

Extended by:
ActiveSupport::Concern
Includes:
ActiveModel::AttributeMethods
Defined in:
lib/massive_record/orm/attribute_methods.rb,
lib/massive_record/orm/attribute_methods/read.rb,
lib/massive_record/orm/attribute_methods/dirty.rb,
lib/massive_record/orm/attribute_methods/write.rb

Defined Under Namespace

Modules: ClassMethods, Dirty, Read, Write

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object



32
33
34
35
36
37
38
39
# File 'lib/massive_record/orm/attribute_methods.rb', line 32

def method_missing(method, *args, &block)
  unless self.class.attribute_methods_generated?
    self.class.define_attribute_methods
    send(method, *args, &block)
  else
    super
  end
end

Instance Method Details

#attributesObject



14
15
16
# File 'lib/massive_record/orm/attribute_methods.rb', line 14

def attributes
  @attributes ||= {}
end

#attributes=(new_attributes) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/massive_record/orm/attribute_methods.rb', line 18

def attributes=(new_attributes)
  return unless new_attributes.is_a?(Hash)

  new_attributes.each do |attr, value|
    writer_method = "#{attr}="
    if respond_to? writer_method
      send(writer_method, value)
    else
      raise UnkownAttributeError.new("Unkown attribute: #{attr}")
    end
  end
end

#respond_to?(*args) ⇒ Boolean

Returns:

  • (Boolean)


41
42
43
44
# File 'lib/massive_record/orm/attribute_methods.rb', line 41

def respond_to?(*args)
  self.class.define_attribute_methods unless self.class.attribute_methods_generated?
  super
end