Class: DutyFree::Config

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/duty_free/config.rb

Overview

Global configuration affecting all threads. Some thread-specific configuration can be found in ‘duty_free.rb`, others in `controller.rb`.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



14
15
16
17
18
19
20
21
# File 'lib/duty_free/config.rb', line 14

def initialize
  # Variables which affect all threads, whose access is synchronized.
  @mutex = Mutex.new
  @enabled = true

  # Variables which affect all threads, whose access is *not* synchronized.
  @serializer = DutyFree::Serializers::YAML
end

Instance Attribute Details

#association_reify_error_behaviourObject

Returns the value of attribute association_reify_error_behaviour.



11
12
13
# File 'lib/duty_free/config.rb', line 11

def association_reify_error_behaviour
  @association_reify_error_behaviour
end

#object_changes_adapterObject

Returns the value of attribute object_changes_adapter.



11
12
13
# File 'lib/duty_free/config.rb', line 11

def object_changes_adapter
  @object_changes_adapter
end

#root_modelObject

Returns the value of attribute root_model.



11
12
13
# File 'lib/duty_free/config.rb', line 11

def root_model
  @root_model
end

#serializerObject

Returns the value of attribute serializer.



11
12
13
# File 'lib/duty_free/config.rb', line 11

def serializer
  @serializer
end

#version_limitObject

Returns the value of attribute version_limit.



11
12
13
# File 'lib/duty_free/config.rb', line 11

def version_limit
  @version_limit
end

Instance Method Details

#enabledObject

Indicates whether DutyFree is on or off. Default: true.



24
25
26
# File 'lib/duty_free/config.rb', line 24

def enabled
  @mutex.synchronize { !!@enabled }
end

#enabled=(enable) ⇒ Object



28
29
30
# File 'lib/duty_free/config.rb', line 28

def enabled=(enable)
  @mutex.synchronize { @enabled = enable }
end