Class: Opensteam::Helpers::ConfigTableHelper::Base

Inherits:
ActionView::Base
  • Object
show all
Includes:
ActionView::Helpers::FormTagHelper, ActionView::Helpers::TagHelper
Defined in:
lib/opensteam/helpers/config_table_helper.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, *args) ⇒ Base

Returns a new instance of Base.



55
56
57
58
59
60
# File 'lib/opensteam/helpers/config_table_helper.rb', line 55

def initialize( name, *args )
  #  args = args.first if args.is_a?(Array)
  @name = name
  @default_include = [] #args[:default_include] || []
  @columns = []
end

Instance Attribute Details

#columnsObject

Returns the value of attribute columns.



53
54
55
# File 'lib/opensteam/helpers/config_table_helper.rb', line 53

def columns
  @columns
end

#default_includeObject

Returns the value of attribute default_include.



53
54
55
# File 'lib/opensteam/helpers/config_table_helper.rb', line 53

def default_include
  @default_include
end

#nameObject

Returns the value of attribute name.



53
54
55
# File 'lib/opensteam/helpers/config_table_helper.rb', line 53

def name
  @name
end

#order_columnObject

Returns the value of attribute order_column.



53
54
55
# File 'lib/opensteam/helpers/config_table_helper.rb', line 53

def order_column
  @order_column
end

Instance Method Details

#[](id) ⇒ Object



74
75
76
# File 'lib/opensteam/helpers/config_table_helper.rb', line 74

def [](id)
  @columns.find { |s| s.id.to_s == id.to_s }
end

#column(id, *args) ⇒ Object



66
67
68
# File 'lib/opensteam/helpers/config_table_helper.rb', line 66

def column(id, *args)
  @columns << Column.new( id, *args )
end

#default_order_column(id) ⇒ Object



70
71
72
# File 'lib/opensteam/helpers/config_table_helper.rb', line 70

def default_order_column(id)
  @order_column = id
end

#include_associations(arr) ⇒ Object



62
63
64
# File 'lib/opensteam/helpers/config_table_helper.rb', line 62

def include_associations(arr)
  @default_include = arr
end

#table_header(&block) ⇒ Object



78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/opensteam/helpers/config_table_helper.rb', line 78

def table_header( &block )
  html_options = {}
  ( :thead, {} ) do
    ( :tr, html_options ) do
      @columns.collect do |c|
        ( :th, {} ) do
          block.call( c )
        end
        
      end
    end
  end
end