Class: Settings::Entry

Inherits:
Node
  • Object
show all
Defined in:
lib/iron/settings/entry.rb

Overview

Represents a leaf in our structure, has a value

Constant Summary

Constants inherited from Node

Node::NODE_SEPARATOR

Instance Attribute Summary collapse

Attributes inherited from Node

#key, #name, #parent, #root

Instance Method Summary collapse

Methods inherited from Node

#group?

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

#defaultObject

Returns the value of attribute default.



6
7
8
# File 'lib/iron/settings/entry.rb', line 6

def default
  @default
end

#typeObject

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

Returns:

  • (Boolean)


15
16
17
# File 'lib/iron/settings/entry.rb', line 15

def entry?
  true
end