Class: BusinessFlow::DSL::FieldList
- Inherits:
-
Object
- Object
- BusinessFlow::DSL::FieldList
- Defined in:
- lib/business_flow/dsl.rb
Overview
Responsible for creating fields on one or more classes and noting the of field
Instance Attribute Summary collapse
-
#field_list ⇒ Object
readonly
Returns the value of attribute field_list.
Instance Method Summary collapse
- #add_field(field) ⇒ Object
- #add_fields(fields) ⇒ Object
-
#initialize(field_list, field_klass, klasses) ⇒ FieldList
constructor
A new instance of FieldList.
Constructor Details
#initialize(field_list, field_klass, klasses) ⇒ FieldList
Returns a new instance of FieldList.
338 339 340 341 342 343 |
# File 'lib/business_flow/dsl.rb', line 338 def initialize(field_list, field_klass, klasses) @field_list = [] @field_klass = field_klass @klasses = [klasses].flatten add_fields(field_list) end |
Instance Attribute Details
#field_list ⇒ Object (readonly)
Returns the value of attribute field_list.
336 337 338 |
# File 'lib/business_flow/dsl.rb', line 336 def field_list @field_list end |
Instance Method Details
#add_field(field) ⇒ Object
353 354 355 356 |
# File 'lib/business_flow/dsl.rb', line 353 def add_field(field) @klasses.each { |klass| field.add_to(klass) } @field_list.push(field.name) end |
#add_fields(fields) ⇒ Object
345 346 347 348 349 350 351 |
# File 'lib/business_flow/dsl.rb', line 345 def add_fields(fields) fields.each do |field| add_field(@field_klass.new(field)) end @field_list.uniq! if fields.present? @field_list end |