Class: Mammoth::Configuration::Providers::HashProvider

Inherits:
Object
  • Object
show all
Defined in:
lib/mammoth/configuration.rb

Overview

Loads configuration from an already parsed Hash.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data, path: nil) ⇒ HashProvider

Returns a new instance of HashProvider.

Parameters:

  • data (Hash)

    configuration data

  • path (String, nil) (defaults to: nil)

    optional source name for diagnostics/status



129
130
131
132
# File 'lib/mammoth/configuration.rb', line 129

def initialize(data, path: nil)
  @data = data
  @path = path || "<hash>"
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



125
126
127
# File 'lib/mammoth/configuration.rb', line 125

def data
  @data
end

#pathObject (readonly)

Returns the value of attribute path.



125
126
127
# File 'lib/mammoth/configuration.rb', line 125

def path
  @path
end

Instance Method Details

#load(schema_path: Configuration::DEFAULT_SCHEMA_PATH) ⇒ Mammoth::Configuration

Parameters:

  • schema_path (String) (defaults to: Configuration::DEFAULT_SCHEMA_PATH)

    JSON Schema path

Returns:



136
137
138
# File 'lib/mammoth/configuration.rb', line 136

def load(schema_path: Configuration::DEFAULT_SCHEMA_PATH)
  Configuration.new(path, schema_path: schema_path, data: deep_copy(data)).load
end