Class: BootstrapAdmin::Attribute

Inherits:
Object
  • Object
show all
Defined in:
lib/bootstrap_admin/attribute.rb

Overview

BootstrapAdmin::Attribute represents a model attribute and stores its name, human_name and a computed “type” which can be one of:

:association
:attribute
:none

(take a look at active_record_extensions).

This is used to build UI elements, see:

app/views/defaults/show
app/views/defaults/form
app/views/defaults/index

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, human_name, type) ⇒ Attribute



18
19
20
# File 'lib/bootstrap_admin/attribute.rb', line 18

def initialize name, human_name, type
  @name, @human_name, @type = name, human_name, type
end

Instance Attribute Details

#human_nameObject (readonly)

Returns the value of attribute human_name.



16
17
18
# File 'lib/bootstrap_admin/attribute.rb', line 16

def human_name
  @human_name
end

#nameObject (readonly)

Returns the value of attribute name.



16
17
18
# File 'lib/bootstrap_admin/attribute.rb', line 16

def name
  @name
end

#typeObject (readonly)

Returns the value of attribute type.



16
17
18
# File 'lib/bootstrap_admin/attribute.rb', line 16

def type
  @type
end

Instance Method Details

#association?true, false



29
# File 'lib/bootstrap_admin/attribute.rb', line 29

def association?; :association == type; end

#attribute?true, false



32
# File 'lib/bootstrap_admin/attribute.rb', line 32

def attribute?; :attribute == type; end

#to_sString



23
# File 'lib/bootstrap_admin/attribute.rb', line 23

def to_s; name.to_s; end

#to_symSymbol



26
# File 'lib/bootstrap_admin/attribute.rb', line 26

def to_sym; to_s.to_sym; end