class SchemaToRxYaml::Settings::Core

Attributes

_settings[RW]

Public Class Methods

name() click to toggle source
# File lib/restfulx/schema_to_rx_yaml.rb, line 23
def name
  instance._settings.key?("name") ? instance.name : super
end
new(name_or_hash = Config.settings_file) click to toggle source
# File lib/restfulx/schema_to_rx_yaml.rb, line 43
def initialize(name_or_hash = Config.settings_file)
  case name_or_hash
  when Hash
    self._settings = name_or_hash
  when String, Symbol
    root_path = defined?(RestfulX::Configuration::APP_ROOT) ? "#{RestfulX::Configuration::APP_ROOT}/config/" : ""
    file_path = name_or_hash.is_a?(Symbol) ? "#{root_path}#{name_or_hash}.yml" : name_or_hash
    self._settings = YAML.load(ERB.new(File.read(file_path)).result)
    self._settings = _settings[RAILS_ENV] if defined?(RAILS_ENV)
  else
    raise ArgumentError.new("Your settings must be a hash, 
      a symbol representing the name of the .yml file in your config directory,
      or a string representing the abosolute path to your settings file.")
  end
  define_settings!
end
reset!() click to toggle source
# File lib/restfulx/schema_to_rx_yaml.rb, line 27
def reset!
  @instance = nil
end