Class: TableCloth::Base
- Inherits:
-
Object
- Object
- TableCloth::Base
- Includes:
- Extensions::Actions, Extensions::RowAttributes
- Defined in:
- lib/table_cloth/base.rb
Constant Summary collapse
- NoPresenterError =
Class.new(Exception)
Instance Attribute Summary collapse
-
#collection ⇒ Object
readonly
Returns the value of attribute collection.
-
#view ⇒ Object
readonly
Returns the value of attribute view.
Class Method Summary collapse
- .add_column(options) ⇒ Object
- .column(*args, &block) ⇒ Object
- .columns ⇒ Object
- .config ⇒ Object
- .presenter(klass = nil) ⇒ Object
Instance Method Summary collapse
- #config ⇒ Object
-
#initialize(collection, view) ⇒ Base
constructor
A new instance of Base.
Constructor Details
#initialize(collection, view) ⇒ Base
Returns a new instance of Base.
10 11 12 13 |
# File 'lib/table_cloth/base.rb', line 10 def initialize(collection, view) @collection = collection @view = view end |
Instance Attribute Details
#collection ⇒ Object (readonly)
Returns the value of attribute collection.
8 9 10 |
# File 'lib/table_cloth/base.rb', line 8 def collection @collection end |
#view ⇒ Object (readonly)
Returns the value of attribute view.
8 9 10 |
# File 'lib/table_cloth/base.rb', line 8 def view @view end |
Class Method Details
.add_column(options) ⇒ Object
51 52 53 54 |
# File 'lib/table_cloth/base.rb', line 51 def add_column() @columns ||= {} @columns[[:name]] = end |
.column(*args, &block) ⇒ Object
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/table_cloth/base.rb', line 31 def column(*args, &block) = args. || {} [:proc] = block if block_given? column_class = .delete(:using) || Column args.each do |name| add_column(class: column_class, options: , name: name) end end |
.columns ⇒ Object
42 43 44 45 46 47 48 49 |
# File 'lib/table_cloth/base.rb', line 42 def columns @columns ||= {} if superclass.respond_to? :columns @columns = superclass.columns.merge(@columns) end @columns end |
.config ⇒ Object
56 57 58 59 60 61 62 |
# File 'lib/table_cloth/base.rb', line 56 def config @config ||= if superclass.respond_to?(:config) superclass.config.dup else Configuration.new end end |
.presenter(klass = nil) ⇒ Object
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/table_cloth/base.rb', line 20 def presenter(klass=nil) return @presenter = klass if klass return @presenter if @presenter if superclass.respond_to?(:presenter) superclass.presenter else raise NoPresenterError, "No Presenter" end end |
Instance Method Details
#config ⇒ Object
15 16 17 |
# File 'lib/table_cloth/base.rb', line 15 def config self.class.config end |