Class: Figure
- Inherits:
-
Hash
- Object
- Hash
- Figure
- Includes:
- DepartmentStore, Store, Singleton
- Defined in:
- lib/figure/store.rb,
lib/figure/figure.rb,
lib/figure/version.rb,
lib/figure/figurine.rb,
lib/figure/department_store.rb
Defined Under Namespace
Modules: DepartmentStore, Store Classes: Figurine
Constant Summary collapse
- CONFIG_GLOBS =
%w|**/*figure.yml **/figure/*.yml **/gaston/*.yml|- VERSION =
"0.0.1"
Class Attribute Summary collapse
-
.config_directory ⇒ Object
Returns the value of attribute config_directory.
-
.env ⇒ Object
Returns the value of attribute env.
Class Method Summary collapse
Instance Method Summary collapse
- #[]=(k, v) ⇒ Object
-
#initialize ⇒ Figure
constructor
A new instance of Figure.
- #store! ⇒ Object
Methods included from Store
#default, #default_store, #has_key?, #merge!
Constructor Details
#initialize ⇒ Figure
Returns a new instance of Figure.
41 42 43 44 |
# File 'lib/figure/figure.rb', line 41 def initialize @config_directory = self.class.config_directory store! end |
Class Attribute Details
.config_directory ⇒ Object
Returns the value of attribute config_directory.
13 14 15 |
# File 'lib/figure/figure.rb', line 13 def config_directory @config_directory end |
.env ⇒ Object
Returns the value of attribute env.
14 15 16 |
# File 'lib/figure/figure.rb', line 14 def env @env end |
Class Method Details
.configure {|_self| ... } ⇒ Object
20 21 22 |
# File 'lib/figure/figure.rb', line 20 def configure yield self end |
.method_missing(*args, m) ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'lib/figure/figure.rb', line 28 def method_missing(*args, m) if @instantiated super else @instantiated = instance send m end end |
.stores ⇒ Object
16 17 18 |
# File 'lib/figure/figure.rb', line 16 def stores @stores ||= {} end |
Instance Method Details
#[]=(k, v) ⇒ Object
65 66 67 68 69 70 71 |
# File 'lib/figure/figure.rb', line 65 def []=(k, v) super.tap do |value| self.class.define_singleton_method k.to_sym do instance.send k end end end |
#store! ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/figure/figure.rb', line 46 def store! config_files.each do |conf| name = conf.basename.to_s.sub('.yml', '').sub('.figure', '') store = new_store name, YAML.load(conf.read) self[name] = if self.class.env if store.respond_to? self.class.env store.send self.class.env else store.merge! self.class.env => {} store[self.class.env] end else store end end end |