Module: Datacaster::Config
Instance Attribute Summary collapse
-
#i18n_exists ⇒ Object
Returns the value of attribute i18n_exists.
-
#i18n_module ⇒ Object
Returns the value of attribute i18n_module.
-
#i18n_t ⇒ Object
Returns the value of attribute i18n_t.
Instance Method Summary collapse
- #add_predefined_caster(name, definition) ⇒ Object
- #i18n_exists? ⇒ Boolean
- #i18n_initialize! ⇒ Object
Instance Attribute Details
#i18n_exists ⇒ Object
Returns the value of attribute i18n_exists.
6 7 8 |
# File 'lib/datacaster/config.rb', line 6 def i18n_exists @i18n_exists end |
#i18n_module ⇒ Object
Returns the value of attribute i18n_module.
7 8 9 |
# File 'lib/datacaster/config.rb', line 7 def i18n_module @i18n_module end |
#i18n_t ⇒ Object
Returns the value of attribute i18n_t.
5 6 7 |
# File 'lib/datacaster/config.rb', line 5 def i18n_t @i18n_t end |
Instance Method Details
#add_predefined_caster(name, definition) ⇒ Object
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/datacaster/config.rb', line 9 def add_predefined_caster(name, definition) case definition when Proc Predefined.define_method(name.to_sym, &definition) when Base Predefined.define_method(name.to_sym) { definition } else raise ArgumentError.new("Expected Datacaster defintion lambda or Datacaster instance") end end |
#i18n_exists? ⇒ Boolean
27 28 29 30 31 32 |
# File 'lib/datacaster/config.rb', line 27 def i18n_exists? if @i18n_t.nil? && @i18n_module.nil? i18n_initialize! end @i18n_exists || ->(*args, **kwargs) { @i18n_module.exists?(*args, **kwargs) } end |
#i18n_initialize! ⇒ Object
34 35 36 37 38 39 40 41 42 |
# File 'lib/datacaster/config.rb', line 34 def i18n_initialize! @i18n_module ||= if defined?(::I18n) I18n else SubstituteI18n end @i18n_module.load_path += [__dir__ + '/../../config/locales/en.yml'] end |