Class: Mack::Data::FieldMgr
- Defined in:
- lib/mack-data_factory/field_manager.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#scopes ⇒ Object
readonly
Returns the value of attribute scopes.
Instance Method Summary collapse
- #add(scope, field_name, options = {}, &block) ⇒ Object
- #fields(scope = :default) ⇒ Object
-
#initialize ⇒ FieldMgr
constructor
A new instance of FieldMgr.
Constructor Details
#initialize ⇒ FieldMgr
Returns a new instance of FieldMgr.
6 7 8 |
# File 'lib/mack-data_factory/field_manager.rb', line 6 def initialize @scopes = {} end |
Instance Attribute Details
#scopes ⇒ Object (readonly)
Returns the value of attribute scopes.
4 5 6 |
# File 'lib/mack-data_factory/field_manager.rb', line 4 def scopes @scopes end |
Instance Method Details
#add(scope, field_name, options = {}, &block) ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'lib/mack-data_factory/field_manager.rb', line 10 def add(scope, field_name, = {}, &block) #default_value = options[:default] || "" field_list = fields(scope) field_list[field_name] = Field.new( :field_name => field_name, :field_rules => ) field_list[field_name].field_value_producer = block if block_given? return field_list end |
#fields(scope = :default) ⇒ Object
19 20 21 22 23 24 |
# File 'lib/mack-data_factory/field_manager.rb', line 19 def fields(scope = :default) if @scopes[scope].nil? @scopes[scope] = {} end return @scopes[scope] end |