Class: Component::ResourceTable
- Defined in:
- app/components/component/resource_table.rb
Instance Attribute Summary collapse
-
#resource ⇒ Object
readonly
Returns the value of attribute resource.
Instance Method Summary collapse
- #association(name, options = {}, &block) ⇒ Object
-
#initialize(*args) ⇒ ResourceTable
constructor
A new instance of ResourceTable.
- #row(name, options = {}, &block) ⇒ Object
- #timestamp(name, options = {}, &block) ⇒ Object
- #timestamps(options = {}) ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(*args) ⇒ ResourceTable
Returns a new instance of ResourceTable.
5 6 7 8 9 10 |
# File 'app/components/component/resource_table.rb', line 5 def initialize(*args) super @rows = {} @resource = @options.delete(:resource) @resource_class = @resource.class end |
Instance Attribute Details
#resource ⇒ Object (readonly)
Returns the value of attribute resource.
3 4 5 |
# File 'app/components/component/resource_table.rb', line 3 def resource @resource end |
Instance Method Details
#association(name, options = {}, &block) ⇒ Object
28 29 30 31 |
# File 'app/components/component/resource_table.rb', line 28 def association(name, = {}, &block) .reverse_merge!(render_as: :association) row(name, , &block) end |
#row(name, options = {}, &block) ⇒ Object
12 13 14 15 16 |
# File 'app/components/component/resource_table.rb', line 12 def row(name, = {}, &block) .reverse_merge!(render_as: :default) .reverse_merge!(block: block) if block_given? @rows[name] = end |
#timestamp(name, options = {}, &block) ⇒ Object
18 19 20 21 |
# File 'app/components/component/resource_table.rb', line 18 def (name, = {}, &block) .reverse_merge!(render_as: :timestamp, format: nil) row(name, , &block) end |
#timestamps(options = {}) ⇒ Object
23 24 25 26 |
# File 'app/components/component/resource_table.rb', line 23 def ( = {}) (:created_at, ) (:updated_at, ) end |