Class: Spectro::Database
- Inherits:
-
Object
- Object
- Spectro::Database
- Extended by:
- Forwardable
- Includes:
- Singleton
- Defined in:
- lib/spectro/database.rb
Overview
Gives access to the current collection of algorithms (lambdas) providing several ways to fetch specific elements by different criterias.
Instance Attribute Summary collapse
-
#cache ⇒ Object
Returns the value of attribute cache.
Instance Method Summary collapse
-
#fetch(file_path, method_name, *required_params) ⇒ Proc
Fetches and return the target lambda based on the given class, method name and required aprameters.
-
#index ⇒ Hash
Lazy loads the index.yml and returns it.
-
#initialize ⇒ Database
constructor
A new instance of Database.
Constructor Details
#initialize ⇒ Database
Returns a new instance of Database.
17 18 19 |
# File 'lib/spectro/database.rb', line 17 def initialize self.cache = {} end |
Instance Attribute Details
#cache ⇒ Object
Returns the value of attribute cache.
15 16 17 |
# File 'lib/spectro/database.rb', line 15 def cache @cache end |
Instance Method Details
#fetch(file_path, method_name, *required_params) ⇒ Proc
Fetches and return the target lambda based on the given class, method name and required aprameters.
35 36 37 38 39 40 41 |
# File 'lib/spectro/database.rb', line 35 def fetch file_path, method_name, *required_params if self.index["#{file_path}"].nil? || self.index["#{file_path}"]["#{method_name}"].nil? return nil end |
#index ⇒ Hash
Lazy loads the index.yml and returns it
24 25 26 |
# File 'lib/spectro/database.rb', line 24 def index @index ||= YAML.load_file('./.spectro/index.yml') end |