Module: GirlScout::Concerns::HasAttributes
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object
30
31
32
33
34
35
|
# File 'lib/girlscout/concerns/has_attributes.rb', line 30
def method_missing(method_name, *args, &block)
key = attr_key(method_name)
return super unless key?(key)
@attributes[key]
end
|
Instance Method Details
14
15
16
|
# File 'lib/girlscout/concerns/has_attributes.rb', line 14
def [](key)
@attributes[attr_key(key)]
end
|
#[]=(key, value) ⇒ Object
18
19
20
|
# File 'lib/girlscout/concerns/has_attributes.rb', line 18
def []=(key, value)
@attributes[attr_key(key)] = value
end
|
10
11
12
|
# File 'lib/girlscout/concerns/has_attributes.rb', line 10
def as_json
@attributes
end
|
#attributes ⇒ Object
6
7
8
|
# File 'lib/girlscout/concerns/has_attributes.rb', line 6
def attributes
@attributes || {}
end
|
#key?(key) ⇒ Boolean
22
23
24
|
# File 'lib/girlscout/concerns/has_attributes.rb', line 22
def key?(key)
@attributes.key?(attr_key(key))
end
|
#respond_to_missing?(method_name, include_all = false) ⇒ Boolean
26
27
28
|
# File 'lib/girlscout/concerns/has_attributes.rb', line 26
def respond_to_missing?(method_name, include_all = false)
key?(method_name) || super
end
|