Module: SuperStack::LayerWrapper
- Includes:
- Comparable, MergePolicies::PolicyHandler
- Included in:
- Layer
- Defined in:
- lib/super_stack/layer_wrapper.rb
Constant Summary collapse
- DEFAULT_LAYER_NAME =
'Unknown layer'
Instance Attribute Summary collapse
-
#disabled ⇒ Object
(also: #disabled?)
readonly
Returns the value of attribute disabled.
-
#file_name ⇒ Object
readonly
Returns the value of attribute file_name.
-
#manager ⇒ Object
readonly
Returns the value of attribute manager.
-
#priority ⇒ Object
Returns the value of attribute priority.
- #source_auto_reload ⇒ Object
Attributes included from MergePolicies::PolicyHandler
Class Method Summary collapse
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #disable_source_auto_reload ⇒ Object
- #enable_source_auto_reload ⇒ Object
- #has_file? ⇒ Boolean
- #inspect ⇒ Object
- #load(file_name = self.file_name, type = :yaml) ⇒ Object
- #name ⇒ Object
- #name=(name) ⇒ Object
- #reload ⇒ Object
- #source_auto_reload? ⇒ Boolean
- #to_hash ⇒ Object
- #to_s ⇒ Object
Instance Attribute Details
#disabled ⇒ Object (readonly) Also known as: disabled?
Returns the value of attribute disabled.
11 12 13 |
# File 'lib/super_stack/layer_wrapper.rb', line 11 def disabled @disabled end |
#file_name ⇒ Object (readonly)
Returns the value of attribute file_name.
11 12 13 |
# File 'lib/super_stack/layer_wrapper.rb', line 11 def file_name @file_name end |
#manager ⇒ Object (readonly)
Returns the value of attribute manager.
11 12 13 |
# File 'lib/super_stack/layer_wrapper.rb', line 11 def manager @manager end |
#priority ⇒ Object
Returns the value of attribute priority.
11 12 13 |
# File 'lib/super_stack/layer_wrapper.rb', line 11 def priority @priority end |
#source_auto_reload ⇒ Object
20 21 22 |
# File 'lib/super_stack/layer_wrapper.rb', line 20 def source_auto_reload @source_auto_reload || false end |
Class Method Details
.from_hash(hash) ⇒ Object
73 74 75 76 77 78 79 |
# File 'lib/super_stack/layer_wrapper.rb', line 73 def self.from_hash(hash) class << hash; include SuperStack::LayerWrapper; end if SuperStack.compatibility_mode class << hash; include SuperStack::Compatibility::LayerWrapper; end end hash end |
Instance Method Details
#<=>(other) ⇒ Object
58 59 60 61 |
# File 'lib/super_stack/layer_wrapper.rb', line 58 def <=>(other) # For priorities, the smallest the higher self.priority <=> other.priority end |
#disable_source_auto_reload ⇒ Object
32 33 34 |
# File 'lib/super_stack/layer_wrapper.rb', line 32 def disable_source_auto_reload self.source_auto_reload = false end |
#enable_source_auto_reload ⇒ Object
28 29 30 |
# File 'lib/super_stack/layer_wrapper.rb', line 28 def enable_source_auto_reload self.source_auto_reload = true end |
#has_file? ⇒ Boolean
54 55 56 |
# File 'lib/super_stack/layer_wrapper.rb', line 54 def has_file? !@file_name.nil? end |
#inspect ⇒ Object
63 64 65 66 67 |
# File 'lib/super_stack/layer_wrapper.rb', line 63 def inspect file_add_on = has_file? ? "file: '#{file_name}', " : '' priority_add_on = priority.nil? ? '' : "priority: #{priority}, " "{name: '#{name}', #{priority_add_on}#{file_add_on}#{super}}" end |
#load(file_name = self.file_name, type = :yaml) ⇒ Object
44 45 46 47 48 |
# File 'lib/super_stack/layer_wrapper.rb', line 44 def load(file_name=self.file_name, type = :yaml) raise "Cannot read file '#{file_name}'" unless File.readable? file_name load_from_yaml file_name if type == :yaml self end |
#name ⇒ Object
40 41 42 |
# File 'lib/super_stack/layer_wrapper.rb', line 40 def name @name || DEFAULT_LAYER_NAME end |
#name=(name) ⇒ Object
36 37 38 |
# File 'lib/super_stack/layer_wrapper.rb', line 36 def name=(name) @name = name.to_s end |
#reload ⇒ Object
50 51 52 |
# File 'lib/super_stack/layer_wrapper.rb', line 50 def reload self.load if has_file? end |
#source_auto_reload? ⇒ Boolean
24 25 26 |
# File 'lib/super_stack/layer_wrapper.rb', line 24 def source_auto_reload? self.source_auto_reload end |
#to_hash ⇒ Object
81 82 83 84 |
# File 'lib/super_stack/layer_wrapper.rb', line 81 def to_hash # Trick to return a bare hash {}.merge self end |
#to_s ⇒ Object
69 70 71 |
# File 'lib/super_stack/layer_wrapper.rb', line 69 def to_s inspect end |