Class: Levels::Audit::Value
- Inherits:
-
Object
- Object
- Levels::Audit::Value
- Defined in:
- lib/levels/audit/value.rb
Overview
The Value represents one piece of configuration data that was originally stored in a Level.
Instance Attribute Summary collapse
-
#level_name ⇒ Object
readonly
Returns a String the name of the level.
-
#value ⇒ Object
(also: #raw)
readonly
Returns the actual value.
Instance Method Summary collapse
-
#add_nested_group_observer(nested_group_observer) ⇒ Object
Private: This is used to accumulate recursive group access.
-
#final? ⇒ Boolean
Returns a Boolean true if this is the final value.
-
#initialize(level_name, final, value = :__no_value__) ⇒ Value
constructor
Initialize a new Value.
- #inspect ⇒ Object
-
#notify(event_handler) ⇒ Object
Public: Trigger a notification of the nested values.
-
#recursive? ⇒ Boolean
Returns a Boolean true if this value is recursive.
Constructor Details
#initialize(level_name, final, value = :__no_value__) ⇒ Value
Initialize a new Value.
level_name - String the name of the level this value was in. final - Boolean true if this is the “final” value for a set of
levels.
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/levels/audit/value.rb', line 13 def initialize(level_name, final, value = :__no_value__) @level_name = level_name @final = final @nested_group_observers = [] if value == :__no_value__ @value = yield self if block_given? else @value = value end end |
Instance Attribute Details
#level_name ⇒ Object (readonly)
Returns a String the name of the level.
25 26 27 |
# File 'lib/levels/audit/value.rb', line 25 def level_name @level_name end |
#value ⇒ Object (readonly) Also known as: raw
Returns the actual value.
28 29 30 |
# File 'lib/levels/audit/value.rb', line 28 def value @value end |
Instance Method Details
#add_nested_group_observer(nested_group_observer) ⇒ Object
Private: This is used to accumulate recursive group access.
54 55 56 |
# File 'lib/levels/audit/value.rb', line 54 def add_nested_group_observer(nested_group_observer) @nested_group_observers << nested_group_observer end |
#final? ⇒ Boolean
Returns a Boolean true if this is the final value.
34 35 36 |
# File 'lib/levels/audit/value.rb', line 34 def final? !!@final end |
#inspect ⇒ Object
58 59 60 |
# File 'lib/levels/audit/value.rb', line 58 def inspect value.inspect end |
#notify(event_handler) ⇒ Object
Public: Trigger a notification of the nested values. For any nested values, the event handler will receive the ‘#on_nested_values` message.
event_handler - Levels::EventHandler.
47 48 49 50 51 |
# File 'lib/levels/audit/value.rb', line 47 def notify(event_handler) @nested_group_observers.each do |ngo| ngo.notify_nested(event_handler) end end |
#recursive? ⇒ Boolean
Returns a Boolean true if this value is recursive.
39 40 41 |
# File 'lib/levels/audit/value.rb', line 39 def recursive? !@nested_group_observers.empty? end |