Class: Spyro::ActionViewExtension::CollectionForHelper::UniData::Collection
- Inherits:
-
Object
- Object
- Spyro::ActionViewExtension::CollectionForHelper::UniData::Collection
- Defined in:
- lib/spyro/helpers/action_view_extension.rb
Instance Attribute Summary collapse
-
#meta ⇒ Object
readonly
Returns the value of attribute meta.
-
#rows ⇒ Object
readonly
Returns the value of attribute rows.
Instance Method Summary collapse
- #add_elem(elem) ⇒ Object
- #add_elem_meta(key, value) ⇒ Object
- #add_meta(key, meta) ⇒ Object
- #has_meta?(key) ⇒ Boolean
-
#initialize ⇒ Collection
constructor
A new instance of Collection.
- #row(&block) ⇒ Object
- #to_s ⇒ Object
- #try_add_meta(key, meta) ⇒ Object
Constructor Details
#initialize ⇒ Collection
Returns a new instance of Collection.
330 331 332 333 |
# File 'lib/spyro/helpers/action_view_extension.rb', line 330 def initialize @rows = [] = {} end |
Instance Attribute Details
#meta ⇒ Object (readonly)
Returns the value of attribute meta.
328 329 330 |
# File 'lib/spyro/helpers/action_view_extension.rb', line 328 def end |
#rows ⇒ Object (readonly)
Returns the value of attribute rows.
328 329 330 |
# File 'lib/spyro/helpers/action_view_extension.rb', line 328 def rows @rows end |
Instance Method Details
#add_elem(elem) ⇒ Object
350 351 352 |
# File 'lib/spyro/helpers/action_view_extension.rb', line 350 def add_elem elem @rows.last[:data] << elem end |
#add_elem_meta(key, value) ⇒ Object
354 355 356 |
# File 'lib/spyro/helpers/action_view_extension.rb', line 354 def key, value @rows.last[:meta][key] = value end |
#add_meta(key, meta) ⇒ Object
335 336 337 |
# File 'lib/spyro/helpers/action_view_extension.rb', line 335 def key, [key] = end |
#has_meta?(key) ⇒ Boolean
343 344 345 |
# File 'lib/spyro/helpers/action_view_extension.rb', line 343 def key ![key].nil? end |
#row(&block) ⇒ Object
347 348 349 350 351 352 353 354 355 356 357 358 359 |
# File 'lib/spyro/helpers/action_view_extension.rb', line 347 def row &block @rows << {:data => [], :meta => {}} def add_elem elem @rows.last[:data] << elem end def key, value @rows.last[:meta][key] = value end block.call self end |
#to_s ⇒ Object
361 362 363 |
# File 'lib/spyro/helpers/action_view_extension.rb', line 361 def to_s "rows: #{@rows} ; meta: #{@meta}" end |
#try_add_meta(key, meta) ⇒ Object
339 340 341 |
# File 'lib/spyro/helpers/action_view_extension.rb', line 339 def key, [key] ||= end |