Class: ProcessSettings::TargetAndSettings
- Inherits:
-
Object
- Object
- ProcessSettings::TargetAndSettings
- Defined in:
- lib/process_settings/target_and_settings.rb
Overview
This class encapsulates a single YAML file with target and process_settings.
Instance Attribute Summary collapse
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
-
#settings ⇒ Object
readonly
Returns the value of attribute settings.
-
#target ⇒ Object
readonly
Returns the value of attribute target.
Class Method Summary collapse
Instance Method Summary collapse
- #==(rhs) ⇒ Object
- #eql?(rhs) ⇒ Boolean
-
#initialize(filename, target, settings) ⇒ TargetAndSettings
constructor
A new instance of TargetAndSettings.
- #to_json_doc ⇒ Object
-
#with_static_context(static_context_hash) ⇒ Object
returns a copy of self with target simplified based on given static_context_hash (or returns self if there is no difference).
Constructor Details
#initialize(filename, target, settings) ⇒ TargetAndSettings
11 12 13 14 15 16 17 18 19 |
# File 'lib/process_settings/target_and_settings.rb', line 11 def initialize(filename, target, settings) @filename = filename target.is_a?(Target) or raise ArgumentError, "target must be a Target; got #{target.inspect}" @target = target settings.is_a?(Settings) or raise ArgumentError, "settings must be a Settings; got #{settings.inspect}" @settings = settings end |
Instance Attribute Details
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
9 10 11 |
# File 'lib/process_settings/target_and_settings.rb', line 9 def filename @filename end |
#settings ⇒ Object (readonly)
Returns the value of attribute settings.
9 10 11 |
# File 'lib/process_settings/target_and_settings.rb', line 9 def settings @settings end |
#target ⇒ Object (readonly)
Returns the value of attribute target.
9 10 11 |
# File 'lib/process_settings/target_and_settings.rb', line 9 def target @target end |
Class Method Details
.from_json_docs(filename, target_json_doc, settings_json_doc) ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/process_settings/target_and_settings.rb', line 37 def from_json_docs(filename, target_json_doc, settings_json_doc) target_json_doc = Target.new(target_json_doc) settings = Settings.new(settings_json_doc) new(filename, target_json_doc, settings) end |
Instance Method Details
#==(rhs) ⇒ Object
21 22 23 |
# File 'lib/process_settings/target_and_settings.rb', line 21 def ==(rhs) to_json_doc == rhs.to_json_doc end |
#eql?(rhs) ⇒ Boolean
25 26 27 |
# File 'lib/process_settings/target_and_settings.rb', line 25 def eql?(rhs) self == rhs end |
#to_json_doc ⇒ Object
29 30 31 32 33 34 |
# File 'lib/process_settings/target_and_settings.rb', line 29 def to_json_doc { "target" => @target.json_doc, "settings" => @settings.json_doc } end |
#with_static_context(static_context_hash) ⇒ Object
returns a copy of self with target simplified based on given static_context_hash (or returns self if there is no difference)
47 48 49 50 51 52 53 54 |
# File 'lib/process_settings/target_and_settings.rb', line 47 def with_static_context(static_context_hash) new_target = target.with_static_context(static_context_hash) if new_target == @target self else self.class.new(@filename, new_target, @settings) end end |