Class: Stacks::Items::ColumnDependentBlock
- Inherits:
-
Object
- Object
- Stacks::Items::ColumnDependentBlock
- Defined in:
- lib/stacks/items/column_dependent_block.rb
Instance Attribute Summary collapse
-
#model ⇒ Object
Returns the value of attribute model.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(model, columns, identifier, proc) ⇒ ColumnDependentBlock
constructor
A new instance of ColumnDependentBlock.
- #key ⇒ Object
- #value ⇒ Object
Constructor Details
#initialize(model, columns, identifier, proc) ⇒ ColumnDependentBlock
Returns a new instance of ColumnDependentBlock.
5 6 7 8 9 10 11 |
# File 'lib/stacks/items/column_dependent_block.rb', line 5 def initialize(model, columns, identifier, proc) @model = model @columns = columns.sort! @columns = @columns.map { |c| c.to_s } @identifier = identifier @proc = proc end |
Instance Attribute Details
#model ⇒ Object
Returns the value of attribute model.
3 4 5 |
# File 'lib/stacks/items/column_dependent_block.rb', line 3 def model @model end |
Class Method Details
.key_to_columns(key) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/stacks/items/column_dependent_block.rb', line 17 def self.key_to_columns(key) all_keys = key.split(Stacks::key_separator) # The identifier takes the first slot all_keys.shift all_keys end |
Instance Method Details
#key ⇒ Object
13 14 15 |
# File 'lib/stacks/items/column_dependent_block.rb', line 13 def key @key ||= [@identifier].concat(@columns).join(Stacks::key_separator) end |
#value ⇒ Object
25 26 27 |
# File 'lib/stacks/items/column_dependent_block.rb', line 25 def value @proc.call end |