Class: MoveToGo::Settings

Inherits:
Object
  • Object
show all
Includes:
SerializeHelper
Defined in:
lib/move-to-go/model/settings.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from SerializeHelper

#get_import_rows, #serialize, #serialize_to_file

Constructor Details

#initialize(opt = nil) ⇒ Settings

Returns a new instance of Settings.



44
45
46
47
48
49
50
51
# File 'lib/move-to-go/model/settings.rb', line 44

def initialize(opt = nil)
    if opt != nil
        serialize_variables.each do |myattr|
            val = opt[myattr[:id]]
            instance_variable_set("@" + myattr[:id].to_s, val) if val != nil
        end
    end
end

Instance Attribute Details

#dealObject (readonly)

Returns the value of attribute deal.



5
6
7
# File 'lib/move-to-go/model/settings.rb', line 5

def deal
  @deal
end

#organizationObject (readonly)

Returns the value of attribute organization.



5
6
7
# File 'lib/move-to-go/model/settings.rb', line 5

def organization
  @organization
end

#personObject (readonly)

Returns the value of attribute person.



5
6
7
# File 'lib/move-to-go/model/settings.rb', line 5

def person
  @person
end

Instance Method Details

#serialize_nameObject



57
58
59
# File 'lib/move-to-go/model/settings.rb', line 57

def serialize_name
    "Settings"
end

#serialize_variablesObject



53
54
55
# File 'lib/move-to-go/model/settings.rb', line 53

def serialize_variables
    [:organization, :person, :deal].map {|p| {:id => p, :type => :class_settings} }
end

#with_deal {|@deal| ... } ⇒ Object

Examples:

Add custom fields available for deal

rootmodel.settings.with_deal do |deal_settings|
    deal_settings.set_custom_field({:integration_id=>"link_to_bi_system", :title=>"Link to BI system"})
end

Yields:

See Also:



39
40
41
42
# File 'lib/move-to-go/model/settings.rb', line 39

def with_deal
    @deal = DealClassSettings.new if @deal ==nil
    yield @deal
end

#with_organization {|@organization| ... } ⇒ Object

Examples:

Add custom fields available for organization

rootmodel.settings.with_organization do |organization_settings|
    organization_settings.set_custom_field({:integration_id=>"link_to_bi_system", :title=>"Link to BI system"})
    organization_settings.set_custom_field({:integration_id=>"yield_quota", :title=>"Yield quota"})
end

Yields:

See Also:



15
16
17
18
# File 'lib/move-to-go/model/settings.rb', line 15

def with_organization
    @organization = ClassSettings.new if @organization ==nil
    yield @organization
end

#with_person {|@person| ... } ⇒ Object

Examples:

Add custom fields available for person

rootmodel.settings.with_person do |person_settings|
    person_settings.set_custom_field({:integration_id=>"link_to_bi_system", :title=>"Link to BI system"})
end

Yields:

See Also:



27
28
29
30
# File 'lib/move-to-go/model/settings.rb', line 27

def with_person
    @person = ClassSettings.new if @person ==nil
    yield @person
end