Class: Mack::Data::FieldMgr

Inherits:
Object show all
Defined in:
lib/mack-data_factory/field_manager.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeFieldMgr

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

#scopesObject (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, options = {}, &block)
  #default_value = options[:default] || ""
  field_list = fields(scope)
  field_list[field_name] = Field.new( :field_name  => field_name, 
                                      :field_rules => options)
  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