Class: ObjectTable::StaticView
- Inherits:
-
Object
- Object
- ObjectTable::StaticView
- Includes:
- ViewMethods
- Defined in:
- lib/object_table/static_view.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#indices ⇒ Object
readonly
Returns the value of attribute indices.
Attributes included from TableMethods
Instance Method Summary collapse
- #add_column(name, *args) ⇒ Object
- #columns ⇒ Object
- #get_column(name) ⇒ Object
-
#initialize(parent, indices) ⇒ StaticView
constructor
A new instance of StaticView.
Methods included from ViewMethods
Methods included from TableChild
#__group_cls__, #__static_view_cls__, #__table_cls__, #__view_cls__
Methods included from TableMethods
#==, #_apply_block, #_get_sort_index, #apply, #clone, #colnames, #group_by, #method_missing, #ncols, #nrows, #pop_column, #respond_to?, #set_column, #sort_by, #where
Methods included from Printable
#_format_rows, #_format_section, calc_column_widths, get_printable_column, #inspect
Constructor Details
#initialize(parent, indices) ⇒ StaticView
Returns a new instance of StaticView.
9 10 11 12 13 14 15 |
# File 'lib/object_table/static_view.rb', line 9 def initialize(parent, indices) super() @parent = parent @indices = indices @columns = ObjectTable::BasicGrid.new @fully_cached = false end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class ObjectTable::TableMethods
Instance Attribute Details
#indices ⇒ Object (readonly)
Returns the value of attribute indices.
7 8 9 |
# File 'lib/object_table/static_view.rb', line 7 def indices @indices end |
Instance Method Details
#add_column(name, *args) ⇒ Object
32 33 34 |
# File 'lib/object_table/static_view.rb', line 32 def add_column(name, *args) @columns[name] = super end |
#columns ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/object_table/static_view.rb', line 17 def columns unless @fully_cached @parent.columns.map{|k, v| get_column(k)} @fully_cached = true end @columns end |
#get_column(name) ⇒ Object
25 26 27 28 29 30 |
# File 'lib/object_table/static_view.rb', line 25 def get_column(name) @columns.fetch(name) do col = super @columns[name] = col if col end end |