Class: ExportTo::Presenter
- Inherits:
-
Object
- Object
- ExportTo::Presenter
- Defined in:
- lib/export_to/presenter.rb
Constant Summary collapse
- NoAttributeError =
Class.new(NoMethodError)
Instance Attribute Summary collapse
-
#model ⇒ Object
Returns the value of attribute model.
-
#relation ⇒ Object
Returns the value of attribute relation.
-
#x ⇒ Object
Returns the value of attribute x.
-
#y ⇒ Object
Returns the value of attribute y.
Instance Method Summary collapse
-
#initialize(model, relation = nil, x, y) ⇒ Presenter
constructor
A new instance of Presenter.
- #method_missing(m, *args, &block) ⇒ Object
- #relation? ⇒ Boolean
Constructor Details
#initialize(model, relation = nil, x, y) ⇒ Presenter
Returns a new instance of Presenter.
6 7 8 9 |
# File 'lib/export_to/presenter.rb', line 6 def initialize(model, relation=nil, x, y) self.model, self.relation = model, relation self.x, self.y = x, y end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(m, *args, &block) ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/export_to/presenter.rb', line 15 def method_missing(m, *args, &block) obj = relation.respond_to?(m) ? relation : model if block_given? obj.public_send(m, *args, &block) else obj.public_send(m, *args) end end |
Instance Attribute Details
#model ⇒ Object
Returns the value of attribute model.
3 4 5 |
# File 'lib/export_to/presenter.rb', line 3 def model @model end |
#relation ⇒ Object
Returns the value of attribute relation.
3 4 5 |
# File 'lib/export_to/presenter.rb', line 3 def relation @relation end |
#x ⇒ Object
Returns the value of attribute x.
3 4 5 |
# File 'lib/export_to/presenter.rb', line 3 def x @x end |
#y ⇒ Object
Returns the value of attribute y.
3 4 5 |
# File 'lib/export_to/presenter.rb', line 3 def y @y end |
Instance Method Details
#relation? ⇒ Boolean
11 12 13 |
# File 'lib/export_to/presenter.rb', line 11 def relation? relation.present? end |