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

Returns a new instance of AttributesList.


411
412
413
414
# File 'app/helpers/application_helper.rb', line 411

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

Instance Attribute Details

#itemsObject (readonly)

Returns the value of attribute items


409
410
411
# File 'app/helpers/application_helper.rb', line 409

def items
  @items
end

Instance Method Details

#attribute(*args) ⇒ Object


416
417
418
# File 'app/helpers/application_helper.rb', line 416

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

#custom(*args) ⇒ Object


420
421
422
# File 'app/helpers/application_helper.rb', line 420

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

#custom_fieldsObject


424
425
426
427
428
429
430
431
# File 'app/helpers/application_helper.rb', line 424

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) if value.present?
  end
  @items << [:custom_fields]
end