Class: Settings::Entry
Overview
Represents a leaf in our structure, has a value
Constant Summary
Constants inherited from Node
Instance Attribute Summary collapse
-
#default ⇒ Object
Returns the value of attribute default.
-
#type ⇒ Object
Returns the value of attribute type.
Attributes inherited from Node
Instance Method Summary collapse
- #default_value(root_cursor, context = nil) ⇒ Object
- #entry? ⇒ Boolean
-
#initialize(parent, type, name, default) ⇒ Entry
constructor
A new instance of Entry.
Methods inherited from Node
Constructor Details
#initialize(parent, type, name, default) ⇒ Entry
Returns a new instance of Entry.
8 9 10 11 12 13 |
# File 'lib/iron/settings/entry.rb', line 8 def initialize(parent, type, name, default) super(parent, name) @type = type @default = default.respond_to?(:call) ? default : Settings.parse(default, type) end |
Instance Attribute Details
#default ⇒ Object
Returns the value of attribute default.
6 7 8 |
# File 'lib/iron/settings/entry.rb', line 6 def default @default end |
#type ⇒ Object
Returns the value of attribute type.
6 7 8 |
# File 'lib/iron/settings/entry.rb', line 6 def type @type end |
Instance Method Details
#default_value(root_cursor, context = nil) ⇒ Object
19 20 21 22 |
# File 'lib/iron/settings/entry.rb', line 19 def default_value(root_cursor, context = nil) return nil if @default.nil? @default.respond_to?(:call) ? Settings.parse(@default.call(context), @type) : DslProxy.exec(root_cursor, @default, context) end |
#entry? ⇒ Boolean
15 16 17 |
# File 'lib/iron/settings/entry.rb', line 15 def entry? true end |