Class: OptionsModel::Base

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Model, Concerns::AttributeAssignment, Concerns::Attributes, Concerns::Serialization
Defined in:
lib/options_model/base.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Concerns::AttributeAssignment

#[], #[]=, #attributes, #fetch, #initialize, #initialize_dup, #nested_attributes, #unused_attributes, #update_attributes

Methods included from Concerns::Serialization

#to_h

Class Method Details

.derive(name = "AnonymousRecord") ⇒ Object



43
44
45
46
47
48
# File 'lib/options_model/base.rb', line 43

def self.derive(name = "AnonymousRecord")
  Class.new(self) do
    include OptionsModel::Concerns::NameHacking
    self.name = name
  end
end

.inspectObject



35
36
37
# File 'lib/options_model/base.rb', line 35

def self.inspect
  "#<#{name}:OptionsModel [#{attribute_names.map(&:inspect).join(', ')}]>"
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?



19
20
21
22
23
24
# File 'lib/options_model/base.rb', line 19

def ==(other)
  other.instance_of?(self.class) &&
    attributes == other.attributes &&
    nested_attributes == other.nested_attributes &&
    unused_attributes == other.unused_attributes
end

#hashObject



27
28
29
# File 'lib/options_model/base.rb', line 27

def hash
  [attributes, nested_attributes, unused_attributes].hash
end

#inspectObject



31
32
33
# File 'lib/options_model/base.rb', line 31

def inspect
  "#<#{self.class.name}:OptionsModel #{self.to_h}>"
end

#persisted?Boolean

Returns:



39
40
41
# File 'lib/options_model/base.rb', line 39

def persisted?
  true
end