Class: ApplicationHelper::AttributesList

Inherits:
Object
  • Object
show all
Defined in:
app/helpers/application_helper.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(object) ⇒ AttributesList


385
386
387
388
# File 'app/helpers/application_helper.rb', line 385

def initialize(object)
  @items = []
  @object = object
end

Instance Attribute Details

#itemsObject (readonly)

Returns the value of attribute items


384
385
386
# File 'app/helpers/application_helper.rb', line 384

def items
  @items
end

Instance Method Details

#attribute(*args) ⇒ Object


390
391
392
# File 'app/helpers/application_helper.rb', line 390

def attribute(*args)
  @items << [:attribute, args]
end

#custom(*args) ⇒ Object


394
395
396
# File 'app/helpers/application_helper.rb', line 394

def custom(*args)
  @items << [:custom, args]
end

#custom_fieldsObject


398
399
400
401
402
403
404
405
# File 'app/helpers/application_helper.rb', line 398

def custom_fields
  raise 'Cannot show custom fields on ' + @object.class.name unless @object.customizable?
  @object.class.custom_fields.each do |custom_field|
    value = @object.custom_value(custom_field)
    custom(custom_field.name, value) unless value.blank?
  end
  @items << [:custom_fields]
end