Class: Noventius::ColumnsGroup
- Inherits:
-
Object
- Object
- Noventius::ColumnsGroup
- Defined in:
- lib/noventius/columns_group.rb
Instance Attribute Summary collapse
-
#columns ⇒ Object
readonly
Returns the value of attribute columns.
-
#label ⇒ Object
readonly
Returns the value of attribute label.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #columns_for_level(level) ⇒ Object
- #deep_dup ⇒ Object
- #depth ⇒ Object
- #html_options ⇒ Object
-
#initialize(name, columns, options = {}) ⇒ ColumnsGroup
constructor
A new instance of ColumnsGroup.
Constructor Details
#initialize(name, columns, options = {}) ⇒ ColumnsGroup
Returns a new instance of ColumnsGroup.
7 8 9 10 11 12 13 |
# File 'lib/noventius/columns_group.rb', line 7 def initialize(name, columns, = {}) @name = name.to_sym @columns = columns @label = .delete(:label) || @name.to_s @label = instance_exec(&@label) if @label.is_a?(Proc) = end |
Instance Attribute Details
#columns ⇒ Object (readonly)
Returns the value of attribute columns.
5 6 7 |
# File 'lib/noventius/columns_group.rb', line 5 def columns @columns end |
#label ⇒ Object (readonly)
Returns the value of attribute label.
5 6 7 |
# File 'lib/noventius/columns_group.rb', line 5 def label @label end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/noventius/columns_group.rb', line 5 def name @name end |
Instance Method Details
#columns_for_level(level) ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'lib/noventius/columns_group.rb', line 27 def columns_for_level(level) if level == 1 @columns else @columns.select { |column| column.is_a?(ColumnsGroup) } .flat_map { |child| child.columns_for_level(level - 1) } end end |
#deep_dup ⇒ Object
19 20 21 |
# File 'lib/noventius/columns_group.rb', line 19 def deep_dup Marshal.load(Marshal.dump(self)) end |
#depth ⇒ Object
23 24 25 |
# File 'lib/noventius/columns_group.rb', line 23 def depth 1 + (@columns.map(&:depth).max || 0) end |
#html_options ⇒ Object
15 16 17 |
# File 'lib/noventius/columns_group.rb', line 15 def [:html_options] || {} end |