Sha256: 2e05e4df31421d52e931ed441dc6b8a6929ed7120849233eede248d888f13903

Contents?: true

Size: 604 Bytes

Versions: 5

Compression:

Stored size: 604 Bytes

Contents

class Settings

  # Represents a leaf in our structure, has a value
  class Entry < Settings::Node
  
    attr_accessor :type, :default
  
    def initialize(parent, type, name, default)
      super(parent, name)

      @type = type
      @default = default.respond_to?(:call) ? default : Settings.parse(default, type)
    end
  
    def entry?
      true
    end
  
    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
  
  end
  
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
iron-settings-1.0.4 lib/iron/settings/entry.rb
iron-settings-1.0.3 lib/iron/settings/entry.rb
iron-settings-1.0.2 lib/iron/settings/entry.rb
iron-settings-1.0.1 lib/iron/settings/entry.rb
iron-settings-1.0.0 lib/iron/settings/entry.rb