Class: BasePresenter
- Inherits:
-
Object
show all
- Defined in:
- lib/base_presenter.rb,
lib/base_presenter/version.rb
Constant Summary
collapse
- VERSION =
"0.0.8"
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(object, template) ⇒ BasePresenter
Returns a new instance of BasePresenter.
6
7
8
9
|
# File 'lib/base_presenter.rb', line 6
def initialize(object, template)
@object = object
@template = template
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(*args, &block) ⇒ Object
11
12
13
|
# File 'lib/base_presenter.rb', line 11
def method_missing(*args, &block)
@template.send(*args, &block)
end
|
Class Method Details
.initialize(object, template) ⇒ Object
24
25
26
27
|
# File 'lib/base_presenter.rb', line 24
def self.initialize(object, template)
@@object = object
@@template = template
end
|
.method_missing(*args, &block) ⇒ Object
35
36
37
|
# File 'lib/base_presenter.rb', line 35
def self.method_missing(*args, &block)
@@template.send(*args, &block)
end
|
.presents(name) ⇒ Object
29
30
31
32
33
|
# File 'lib/base_presenter.rb', line 29
def self.presents(name)
define_method(name) do
@object
end
end
|
Instance Method Details
#handle_none(value) ⇒ Object
Return span with ‘None given’ when value is blank
16
17
18
19
20
21
22
|
# File 'lib/base_presenter.rb', line 16
def handle_none(value)
if value.present?
yield
else
content_tag :span, "None given", class: "none"
end
end
|