Class: Component::ResourceTable
- Includes:
- BooleanConcern
- Defined in:
- app/components/component/resource_table.rb
Defined Under Namespace
Modules: BooleanConcern
Instance Attribute Summary collapse
-
#resource ⇒ Object
readonly
Returns the value of attribute resource.
Instance Method Summary collapse
- #association(name, options = {}, &block) ⇒ Object
- #id(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 included from BooleanConcern
Methods inherited from Base
Constructor Details
#initialize(*args) ⇒ ResourceTable
7 8 9 10 11 12 |
# File 'app/components/component/resource_table.rb', line 7 def initialize(*args) super @rows = {} @resource = .delete(:resource) @resource_class = @resource.class end |
Instance Attribute Details
#resource ⇒ Object (readonly)
Returns the value of attribute resource
5 6 7 |
# File 'app/components/component/resource_table.rb', line 5 def resource @resource end |
Instance Method Details
#association(name, options = {}, &block) ⇒ Object
34 35 36 37 |
# File 'app/components/component/resource_table.rb', line 34 def association(name, = {}, &block) .reverse_merge!(render_as: :association) row(name, , &block) end |
#id(options = {}, &block) ⇒ Object
20 21 22 |
# File 'app/components/component/resource_table.rb', line 20 def id( = {}, &block) row(:id, , &block) end |
#row(name, options = {}, &block) ⇒ Object
14 15 16 17 18 |
# File 'app/components/component/resource_table.rb', line 14 def row(name, = {}, &block) .reverse_merge!(render_as: :default) .reverse_merge!(block: block) if block_given? @rows[name] = end |
#timestamp(name, options = {}, &block) ⇒ Object
24 25 26 27 |
# File 'app/components/component/resource_table.rb', line 24 def (name, = {}, &block) .reverse_merge!(render_as: :timestamp, format: Rails::AddOns::Configuration.) row(name, , &block) end |
#timestamps(options = {}) ⇒ Object
29 30 31 32 |
# File 'app/components/component/resource_table.rb', line 29 def ( = {}) (:created_at, ) (:updated_at, ) end |