Module: Masterman::InstanceAccessor
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/masterman/instance_accessor.rb
Defined Under Namespace
Classes: GeneratedAttributeReaders
Instance Method Summary
collapse
Instance Method Details
#==(other) ⇒ Object
54
55
56
57
58
|
# File 'lib/masterman/instance_accessor.rb', line 54
def ==(other)
other.is_a?(self.class) &&
!other[self.class.masterman.primary_key].nil? &&
other.attributes == attributes
end
|
#[](key) ⇒ Object
67
68
69
|
# File 'lib/masterman/instance_accessor.rb', line 67
def [](key)
public_send(key)
end
|
#attributes ⇒ Object
60
61
62
63
64
65
|
# File 'lib/masterman/instance_accessor.rb', line 60
def attributes
masterman.attr_readers.each_with_object({}) do |attr, memo|
value = public_send(attr)
memo[attr.to_s] = value if value
end
end
|
#initialize(attributes = {}) ⇒ Object
46
47
48
49
50
51
52
|
# File 'lib/masterman/instance_accessor.rb', line 46
def initialize(attributes = {})
initialize_generated_attr_readers unless self.class.generated_attr_readers
attributes.each do |key, value|
instance_variable_set(:"@#{key}", value)
end
end
|