Module: Amiando::Attributes
Defined Under Namespace
Modules: ClassMethods
Class Method Summary
collapse
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object
80
81
82
83
84
85
86
|
# File 'lib/amiando/attributes.rb', line 80
def method_missing(method_name, *args, &block)
if attributes.key?(method_name) && args.empty?
attributes[method_name]
else
super
end
end
|
Class Method Details
.included(base) ⇒ Object
3
4
5
6
7
8
|
# File 'lib/amiando/attributes.rb', line 3
def self.included(base)
base.class_eval do
attr_reader :attributes
extend ClassMethods
end
end
|
Instance Method Details
#[](key) ⇒ Object
72
73
74
|
# File 'lib/amiando/attributes.rb', line 72
def [](key)
@attributes[key.to_sym]
end
|
#id ⇒ Object
64
65
66
|
# File 'lib/amiando/attributes.rb', line 64
def id
attributes[:id]
end
|
#respond_to?(method_name, include_private = false) ⇒ Boolean
76
77
78
|
# File 'lib/amiando/attributes.rb', line 76
def respond_to?(method_name, include_private = false)
super || attributes.key?(method_name)
end
|
#type ⇒ Object
68
69
70
|
# File 'lib/amiando/attributes.rb', line 68
def type
attributes[:type]
end
|