Module: Confstruct
- Defined in:
- lib/confstruct.rb,
lib/confstruct/configuration.rb,
lib/confstruct/hash_with_struct_access.rb
Defined Under Namespace
Classes: Configuration, Deferred, HashWithStructAccess
Constant Summary
collapse
- VERSION =
'0.2.7'
Class Method Summary
collapse
Class Method Details
.deferred(&block) ⇒ Object
18
|
# File 'lib/confstruct/hash_with_struct_access.rb', line 18
def self.deferred █ Deferred.new(&block); end
|
.i18n(key = nil, &block) ⇒ Object
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/confstruct/hash_with_struct_access.rb', line 20
def self.i18n key=nil, &block
raise NameError, "I18n handler not loaded" unless Object.const_defined? :I18n Deferred.new do |hwsa|
val = block_given? ? eval_or_yield(hwsa, &block) : key
if val.is_a?(Date) or val.is_a?(Time) or val.is_a?(DateTime)
::I18n.localize val
else
::I18n.translate val
end
end
end
|