Module: Trestle::Configurable
- Extended by:
- ActiveSupport::Concern
- Included in:
- Configuration
- Defined in:
- lib/trestle/configurable.rb
Defined Under Namespace
Modules: ClassMethods, Open
Instance Method Summary
collapse
Instance Method Details
#as_json(options = nil) ⇒ Object
37
38
39
40
41
|
# File 'lib/trestle/configurable.rb', line 37
def as_json(options=nil)
@options.each_with_object({}) do |(k, v), h|
h[k] = v.as_json(options)
end
end
|
#assign(name, value) ⇒ Object
29
30
31
|
# File 'lib/trestle/configurable.rb', line 29
def assign(name, value)
options[name.to_sym] = value
end
|
7
8
9
10
|
# File 'lib/trestle/configurable.rb', line 7
def configure(&block)
yield self if block_given?
self
end
|
#fetch(name) ⇒ Object
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/trestle/configurable.rb', line 12
def fetch(name)
name = name.to_sym
options.fetch(name) {
if defaults.key?(name)
value = defaults[name]
if value.respond_to?(:dup) && !value.is_a?(Proc)
value = value.dup
end
assign(name, value)
end
}
end
|
#inspect ⇒ Object
43
44
45
|
# File 'lib/trestle/configurable.rb', line 43
def inspect
"#<#{self.class.name || "Anonymous(Trestle::Configurable)"}>"
end
|
#options ⇒ Object
33
34
35
|
# File 'lib/trestle/configurable.rb', line 33
def options
@options ||= {}
end
|