Class: AppCfg::Source
- Inherits:
-
Object
- Object
- AppCfg::Source
- Defined in:
- lib/appcfg/source.rb
Direct Known Subclasses
Constant Summary collapse
- @@sources =
[]
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Source
constructor
A new instance of Source.
- #reload_data! ⇒ Object
- #to_hash ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Source
Returns a new instance of Source.
9 10 11 |
# File 'lib/appcfg/source.rb', line 9 def initialize(={}) @hash = end |
Class Method Details
.add(source_object, options = {}) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/appcfg/source.rb', line 21 def self.add(source_object, ={}) if source_object.is_a?(String) && source_object[-4..-1] == '.yml' #YAML raise "File #{source_object} could not be located" unless File.exist? source_object add_source(YamlSource.new(.merge(:file => source_object))) elsif source_object.is_a?(Class) && source_object.respond_to?(:all) #AR Model add_source(ModelSource.new(.merge(:class => source_object))) elsif source_object.is_a?(Hash) #Simple hash add_source(Source.new(source_object)) else raise 'Could not match source object to any known types' end end |
.clear ⇒ Object
37 38 39 40 |
# File 'lib/appcfg/source.rb', line 37 def self.clear @@sources = [] reload_sources! end |
.list ⇒ Object
42 43 44 |
# File 'lib/appcfg/source.rb', line 42 def self.list @@sources end |
Instance Method Details
#reload_data! ⇒ Object
17 18 19 |
# File 'lib/appcfg/source.rb', line 17 def reload_data! #Do nothing end |
#to_hash ⇒ Object
13 14 15 |
# File 'lib/appcfg/source.rb', line 13 def to_hash @hash end |