Class: InteriorDecorator
- Inherits:
-
Object
show all
- Defined in:
- lib/interior_decorator.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of InteriorDecorator.
13
14
15
|
# File 'lib/interior_decorator.rb', line 13
def initialize(model)
@model = model
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object
22
23
24
25
26
27
28
|
# File 'lib/interior_decorator.rb', line 22
def method_missing(method_name, *args, &block)
if model.respond_to?(method_name)
model.public_send(method_name, *args, &block)
else
super
end
end
|
Instance Attribute Details
#model ⇒ Object
Returns the value of attribute model.
3
4
5
|
# File 'lib/interior_decorator.rb', line 3
def model
@model
end
|
Class Method Details
.decorate(item) ⇒ Object
5
6
7
8
9
10
11
|
# File 'lib/interior_decorator.rb', line 5
def self.decorate(item)
if item.respond_to?(:map)
item.map { |object| new(object) }
else
new(item)
end
end
|
Instance Method Details
#helper ⇒ Object
Also known as:
h
17
18
19
|
# File 'lib/interior_decorator.rb', line 17
def helper
ActionController::Base.helpers
end
|
#respond_to_missing?(method_name, include_private = false) ⇒ Boolean
30
31
32
|
# File 'lib/interior_decorator.rb', line 30
def respond_to_missing?(method_name, include_private = false)
model.respond_to?(method_name, include_private)
end
|