Class: Spyro::ActionViewExtension::CollectionForHelper::UniData::Collection

Inherits:
Object
  • Object
show all
Defined in:
lib/spyro/helpers/action_view_extension.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCollection

Returns a new instance of Collection.



330
331
332
333
# File 'lib/spyro/helpers/action_view_extension.rb', line 330

def initialize
  @rows = []
  @meta = {}
end

Instance Attribute Details

#metaObject (readonly)

Returns the value of attribute meta.



328
329
330
# File 'lib/spyro/helpers/action_view_extension.rb', line 328

def meta
  @meta
end

#rowsObject (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 add_elem_meta 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 add_meta key, meta
  @meta[key] = meta
end

#has_meta?(key) ⇒ Boolean

Returns:

  • (Boolean)


343
344
345
# File 'lib/spyro/helpers/action_view_extension.rb', line 343

def has_meta? key
  !@meta[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 add_elem_meta key, value
    @rows.last[:meta][key] = value
  end

  block.call self
end

#to_sObject



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 try_add_meta key, meta
  @meta[key] ||= meta
end