Module: Mastar::ClassMethods
- Defined in:
- lib/mastar.rb
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object
56
57
58
59
60
61
62
63
|
# File 'lib/mastar.rb', line 56
def method_missing(name, *args)
if mastar_config.key
define_direct_method(name)
respond_to?(name) ? __send__(name, *args) : nil
else
super
end
end
|
Instance Method Details
#get(id) ⇒ Object
22
23
24
25
|
# File 'lib/mastar.rb', line 22
def get(id)
mastar_records[id] ||= find(id)
mastar_records[id]
end
|
#pairs(options = {}) ⇒ Object
15
16
17
18
19
20
|
# File 'lib/mastar.rb', line 15
def pairs(options = {})
opts = safe_options(options)
name = (opts, :name, mastar_config.name)
value = (opts, :value, mastar_config.value)
self.select([name, value]).map { |r| NameValuePair.new(r.__send__(name), r.__send__(value)) }
end
|