Class: K3Testing::Presenter
- Inherits:
-
Object
- Object
- K3Testing::Presenter
- Defined in:
- lib/k3_testing/presenter.rb
Instance Attribute Summary collapse
-
#object ⇒ Object
readonly
Returns the value of attribute object.
Instance Method Summary collapse
- #attr(name, options = {}, &block) ⇒ Object
-
#initialize(obj, parent) ⇒ Presenter
constructor
A new instance of Presenter.
Constructor Details
#initialize(obj, parent) ⇒ Presenter
Returns a new instance of Presenter.
97 98 99 100 |
# File 'lib/k3_testing/presenter.rb', line 97 def initialize(obj, parent) @object = obj @parent = parent end |
Instance Attribute Details
#object ⇒ Object (readonly)
Returns the value of attribute object.
95 96 97 |
# File 'lib/k3_testing/presenter.rb', line 95 def object @object end |
Instance Method Details
#attr(name, options = {}, &block) ⇒ Object
102 103 104 105 106 107 |
# File 'lib/k3_testing/presenter.rb', line 102 def attr(name, ={}, &block) tag = [:as] || :span output = block.nil? ? object.send(name).to_s : @parent.capture(&block) html_opts = ([:html_options] || {}).merge('data-role' => "#{object.class.name.underscore}.#{object.id}.#{name.to_s}") @parent.content_tag tag, output, html_opts end |