Class: Figure
- Inherits:
-
Hash
show all
- Includes:
- DepartmentStore, Store, Singleton
- Defined in:
- lib/figure.rb,
lib/figure.rb,
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, GastonInitializer, RailsInitializer
Constant Summary
collapse
- CONFIG_GLOBS =
%w|**/*figure.yml **/figure/*.yml **/gaston/*.yml|
- VERSION =
"0.0.2"
Class Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Store
#complete_defaults, #default, #figures, #has_key?, #merge!
Constructor Details
#initialize ⇒ Figure
48
49
50
51
52
|
# File 'lib/figure/figure.rb', line 48
def initialize
self.class.initializers.each &:initialize!
@config_directories = self.class.config_directories.map { |path| Pathname.new path }
store!
end
|
Class Attribute Details
.env ⇒ Object
Returns the value of attribute env.
13
14
15
|
# File 'lib/figure/figure.rb', line 13
def env
@env
end
|
Class Method Details
.config_directories ⇒ Object
19
20
21
|
# File 'lib/figure/figure.rb', line 19
def config_directories
@config_directories ||= []
end
|
31
32
33
|
# File 'lib/figure/figure.rb', line 31
def configure
yield self
end
|
.initializers ⇒ Object
15
16
17
|
# File 'lib/figure/figure.rb', line 15
def initializers
@initializers ||= []
end
|
.method_missing(*args, m) ⇒ Object
35
36
37
38
39
40
41
42
|
# File 'lib/figure/figure.rb', line 35
def method_missing(*args, m)
if @instantiated
super
else
@instantiated = instance
send m
end
end
|
.responders ⇒ Object
23
24
25
|
# File 'lib/figure/figure.rb', line 23
def responders
@responders ||= []
end
|
.stores ⇒ Object
27
28
29
|
# File 'lib/figure/figure.rb', line 27
def stores
@stores ||= {}
end
|
Instance Method Details
#[]=(k, v) ⇒ Object
60
61
62
63
64
65
66
|
# File 'lib/figure/figure.rb', line 60
def []=(k, v)
super.tap do |value|
self.class.define_singleton_method k.to_sym do
instance.send k
end
end
end
|
#config_files ⇒ Object
68
69
70
71
72
73
74
75
|
# File 'lib/figure/figure.rb', line 68
def config_files
Dir[ *all_config_directories_globs ].map do |file|
path = Pathname.new file
name = path.basename.to_s.sub('.yml', '').sub('.figure', '')
yield name, path if block_given?
end
end
|
#store! ⇒ Object
54
55
56
57
58
|
# File 'lib/figure/figure.rb', line 54
def store!
config_files do |name, conf|
self[name.to_sym] = new_store name, YAML.load(conf.read)
end
end
|