Class: Railstar::CodeHolder
- Inherits:
-
Hash
- Object
- Hash
- Railstar::CodeHolder
- Defined in:
- lib/railstar/code_holder.rb
Instance Method Summary collapse
- #codes ⇒ Object
-
#initialize ⇒ CodeHolder
constructor
A new instance of CodeHolder.
- #load(name, options = {}) ⇒ Object
- #method_missing(name, *args) ⇒ Object
Constructor Details
#initialize ⇒ CodeHolder
Returns a new instance of CodeHolder.
10 11 |
# File 'lib/railstar/code_holder.rb', line 10 def initialize end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object
13 14 15 |
# File 'lib/railstar/code_holder.rb', line 13 def method_missing(name, *args) self[name] ||= load(name, *args) end |
Instance Method Details
#codes ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/railstar/code_holder.rb', line 21 def codes dirs = Dir.glob(File.join(Rails.root, "resources", "code", "*.csv")) dirs += Dir.glob(File.join(Railstar.code_dir, "*.csv")) files = [] dirs.each do |dir| files << dir.split("/").last end files.sort.uniq.map{|a| a.sub(/.csv$/, "")} end |