Class: SchemaToYaml::Settings::Core
- Inherits:
-
Object
- Object
- SchemaToYaml::Settings::Core
- Defined in:
- lib/restfulx/rails/schema_to_yaml/settings/core.rb
Instance Attribute Summary collapse
-
#_settings ⇒ Object
Returns the value of attribute _settings.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name_or_hash = Config.settings_file) ⇒ Core
constructor
A new instance of Core.
Constructor Details
#initialize(name_or_hash = Config.settings_file) ⇒ Core
Returns a new instance of Core.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/restfulx/rails/schema_to_yaml/settings/core.rb', line 30 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?(APP_ROOT) ? "#{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 |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object (private)
48 49 50 |
# File 'lib/restfulx/rails/schema_to_yaml/settings/core.rb', line 48 def method_missing(name, *args, &block) raise NoMethodError.new("no configuration was specified for #{name}") end |
Instance Attribute Details
#_settings ⇒ Object
Returns the value of attribute _settings.
28 29 30 |
# File 'lib/restfulx/rails/schema_to_yaml/settings/core.rb', line 28 def _settings @_settings end |
Class Method Details
.name ⇒ Object
10 11 12 |
# File 'lib/restfulx/rails/schema_to_yaml/settings/core.rb', line 10 def name instance._settings.key?("name") ? instance.name : super end |
.reset! ⇒ Object
14 15 16 |
# File 'lib/restfulx/rails/schema_to_yaml/settings/core.rb', line 14 def reset! @instance = nil end |