Class: Bourgeois::Presenter
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Bourgeois::Presenter
- Defined in:
- lib/bourgeois/presenter.rb
Instance Attribute Summary collapse
-
#object ⇒ Object
readonly
Return the original delegated object.
Class Method Summary collapse
-
.helper(name, opts = {}) ⇒ Object
Declare a new block helper method.
-
.human_attribute_name(*args) ⇒ Object
ActionView::Helpers::FormBuilder needs this too.
-
.model_name ⇒ Object
ActionView::Helpers::FormBuilder needs this.
Instance Method Summary collapse
-
#initialize(object, view = nil) ⇒ Presenter
constructor
A new instance of Presenter.
-
#inspect ⇒ Object
Return a String representation of the presenter + the original object.
-
#kind_of?(mod) ⇒ Boolean
We need to explicitely define this method because it’s not catched by the delegator.
Constructor Details
#initialize(object, view = nil) ⇒ Presenter
Returns a new instance of Presenter.
6 7 8 9 |
# File 'lib/bourgeois/presenter.rb', line 6 def initialize(object, view = nil) @view = view super(@object = object) end |
Instance Attribute Details
#object ⇒ Object (readonly)
Return the original delegated object
4 5 6 |
# File 'lib/bourgeois/presenter.rb', line 4 def object @object end |
Class Method Details
.helper(name, opts = {}) ⇒ Object
Declare a new block helper method
44 45 46 47 48 |
# File 'lib/bourgeois/presenter.rb', line 44 def self.helper(name, opts = {}) define_method(name) do |&block| execute_helper(block, opts) end end |
.human_attribute_name(*args) ⇒ Object
ActionView::Helpers::FormBuilder needs this too
28 29 30 |
# File 'lib/bourgeois/presenter.rb', line 28 def self.human_attribute_name(*args) klass.human_attribute_name(*args) end |
.model_name ⇒ Object
ActionView::Helpers::FormBuilder needs this
23 24 25 |
# File 'lib/bourgeois/presenter.rb', line 23 def self.model_name klass.model_name end |
Instance Method Details
#inspect ⇒ Object
Return a String representation of the presenter + the original object
12 13 14 |
# File 'lib/bourgeois/presenter.rb', line 12 def inspect "#<#{self.class} object=#{@object.inspect}>" end |
#kind_of?(mod) ⇒ Boolean
We need to explicitely define this method because it’s not catched by the delegator
18 19 20 |
# File 'lib/bourgeois/presenter.rb', line 18 def kind_of?(mod) @object.kind_of?(mod) end |