Class: Workarea::Content::Fieldset
- Inherits:
-
Object
- Object
- Workarea::Content::Fieldset
- Includes:
- AssetLookup
- Defined in:
- app/models/workarea/content/fieldset.rb
Instance Attribute Summary collapse
-
#field_suffix ⇒ Object
Returns the value of attribute field_suffix.
-
#fields ⇒ Object
readonly
Returns the value of attribute fields.
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
- #field(name, type, options = {}) ⇒ Object
-
#initialize(name) ⇒ Fieldset
constructor
A new instance of Fieldset.
Methods included from AssetLookup
Constructor Details
#initialize(name) ⇒ Fieldset
Returns a new instance of Fieldset.
9 10 11 12 |
# File 'app/models/workarea/content/fieldset.rb', line 9 def initialize(name) @name = name @fields = [] end |
Instance Attribute Details
#field_suffix ⇒ Object
Returns the value of attribute field_suffix.
7 8 9 |
# File 'app/models/workarea/content/fieldset.rb', line 7 def field_suffix @field_suffix end |
#fields ⇒ Object (readonly)
Returns the value of attribute fields.
6 7 8 |
# File 'app/models/workarea/content/fieldset.rb', line 6 def fields @fields end |
#name ⇒ Object
Returns the value of attribute name.
7 8 9 |
# File 'app/models/workarea/content/fieldset.rb', line 7 def name @name end |
Instance Method Details
#field(name, type, options = {}) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'app/models/workarea/content/fieldset.rb', line 14 def field(name, type, = {}) name = [name, field_suffix].join if field_suffix.present? klass = if type.is_a?(Class) type else "Workarea::Content::Fields::#{type.to_s.camelize}".constantize end if existing = @fields.detect { |f| f.name == name } existing..merge!() else @fields << klass.new(name, ) end end |