Module: MongoModel::AttributeMethods

Extended by:
ActiveSupport::Concern
Includes:
ActiveModel::AttributeMethods
Included in:
EmbeddedDocument
Defined in:
lib/mongomodel.rb,
lib/mongomodel/concerns/attribute_methods.rb,
lib/mongomodel/concerns/attribute_methods/read.rb,
lib/mongomodel/concerns/attribute_methods/dirty.rb,
lib/mongomodel/concerns/attribute_methods/query.rb,
lib/mongomodel/concerns/attribute_methods/write.rb,
lib/mongomodel/concerns/attribute_methods/nested.rb,
lib/mongomodel/concerns/attribute_methods/forbidden.rb,
lib/mongomodel/concerns/attribute_methods/protected.rb,
lib/mongomodel/concerns/attribute_methods/before_type_cast.rb,
lib/mongomodel/concerns/attribute_methods/multi_parameter_assignment.rb

Defined Under Namespace

Modules: BeforeTypeCast, ClassMethods, Dirty, Forbidden, MultiParameterAssignment, Nested, Protected, Query, 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



40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/mongomodel/concerns/attribute_methods.rb', line 40

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

    if respond_to_without_attributes?(method)
      send(method, *args, &block)
    else
      super
    end
  else
    super
  end
end

Instance Method Details

#clone_attribute_value(attribute_name) ⇒ Object



59
60
61
62
63
64
# File 'lib/mongomodel/concerns/attribute_methods.rb', line 59

def clone_attribute_value(attribute_name)
  value = read_attribute(attribute_name)
  value.duplicable? ? value.clone : value
rescue TypeError, NoMethodError
  value
end

#respond_to?(*args) ⇒ Boolean

Returns:



54
55
56
57
# File 'lib/mongomodel/concerns/attribute_methods.rb', line 54

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