Class: Refinery::LocationExplorer::OwnerDecorator
- Inherits:
-
Object
- Object
- Refinery::LocationExplorer::OwnerDecorator
show all
- Defined in:
- app/models/refinery/location_explorer/owner_decorator.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of OwnerDecorator.
14
15
16
|
# File 'app/models/refinery/location_explorer/owner_decorator.rb', line 14
def initialize(subject)
@subject = subject
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args, &block) ⇒ Object
18
19
20
|
# File 'app/models/refinery/location_explorer/owner_decorator.rb', line 18
def method_missing(sym, *args, &block)
@subject.send sym, *args, &block
end
|
Class Method Details
.use_owner_attribute(*keys) ⇒ Object
4
5
6
7
8
9
10
|
# File 'app/models/refinery/location_explorer/owner_decorator.rb', line 4
def self.use_owner_attribute(*keys)
keys.each do |key|
define_method(key) do
owner.send(key) || @subject.send(key)
end
end
end
|
Instance Method Details
#as_json(options = {}) ⇒ Object
22
23
24
25
26
27
28
29
|
# File 'app/models/refinery/location_explorer/owner_decorator.rb', line 22
def as_json(options = {})
results = {}
methods = [:latitude, :longitude, :name] + (options[:methods] || [])
methods.each do |method|
results[method.to_s] = send(method)
end
results.as_json
end
|
#detail_url ⇒ Object
31
32
33
|
# File 'app/models/refinery/location_explorer/owner_decorator.rb', line 31
def detail_url
"/#{owner_resource_name}/#{owner.to_param}"
end
|