Class: DynamicScaffold::List::Item
- Inherits:
-
Object
- Object
- DynamicScaffold::List::Item
- Defined in:
- lib/dynamic_scaffold/list/item.rb
Instance Attribute Summary collapse
-
#classnames ⇒ Object
readonly
Returns the value of attribute classnames.
-
#html_attributes ⇒ Object
readonly
Returns the value of attribute html_attributes.
Instance Method Summary collapse
-
#initialize(config, *args, block) ⇒ Item
constructor
A new instance of Item.
- #label(label = nil, &block) ⇒ Object
- #value(view, record) ⇒ Object
Constructor Details
#initialize(config, *args, block) ⇒ Item
Returns a new instance of Item.
6 7 8 9 10 11 12 |
# File 'lib/dynamic_scaffold/list/item.rb', line 6 def initialize(config, *args, block) @config = config @html_attributes = args. @classnames = @html_attributes.delete(:class) @attribute_name = args[0] @block = block end |
Instance Attribute Details
#classnames ⇒ Object (readonly)
Returns the value of attribute classnames.
4 5 6 |
# File 'lib/dynamic_scaffold/list/item.rb', line 4 def classnames @classnames end |
#html_attributes ⇒ Object (readonly)
Returns the value of attribute html_attributes.
4 5 6 |
# File 'lib/dynamic_scaffold/list/item.rb', line 4 def html_attributes @html_attributes end |
Instance Method Details
#label(label = nil, &block) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/dynamic_scaffold/list/item.rb', line 22 def label(label = nil, &block) @block = block if block if label @label = label self elsif @label @label elsif @attribute_name @config.model.human_attribute_name @attribute_name end end |
#value(view, record) ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/dynamic_scaffold/list/item.rb', line 14 def value(view, record) if @block view.instance_exec(record, @attribute_name, &@block) else record.public_send(@attribute_name) end end |