Class: I18n::Inflector::InflectionOptions
- Inherits:
-
Object
- Object
- I18n::Inflector::InflectionOptions
- Defined in:
- lib/i18n-inflector-rails/options.rb
Overview
This module adds options to InflectionOptions
Instance Attribute Summary collapse
-
#auto_helper ⇒ Object
When this is set to
truethen each time infleciton method is registered it becomes a helper method so it's available in a view. -
#lazy_methods ⇒ Object
When this is set to
truethen each time an infleciton method is used to obtain value for the associated kind it evaluates lazy. -
#verify_methods ⇒ Object
When this is set to
truethen inflection works a bit slower but checks whether any method exists before calling it.
Instance Method Summary collapse
-
#reset ⇒ Object
This method resets inflector's switches to default values.
Instance Attribute Details
#auto_helper ⇒ Object
When this is set to true then
each time infleciton method is registered
it becomes a helper method so it's available in
a view.
This switch is by default set
to true.
Setting this switch locally, for the specified translation call, using :inflector_auto_helper option will have no effect.
54 55 56 |
# File 'lib/i18n-inflector-rails/options.rb', line 54 def auto_helper @auto_helper end |
#lazy_methods ⇒ Object
When this is set to true then
each time an infleciton method is used to obtain
value for the associated kind it evaluates lazy.
That means the method object is passed to the
translation routines and it is evaluated when there
is a need. If this is set to false then
evaluation takes place before calling Inflector's
translation method and inflection options are passed
as symbols, not as method objects.
This switch is by default set
to true. By disabling it you may experience
some negative performance impact when many
inflection methods are registered. That is because
the lazy evaluation causes calling only those methods
that are needed by internal interpolation routines
of the Inflector. For instance, if in some pattern
only the kind "gender" is used then there is no
need to call inflection methods for other kinds.
When lazy evaluation is disabled then all inflection
methods have to be called before passing control
to translation routines, since this plug-in does not
analyze contents of inflection patterns or keys.
Alternatively you can turn this off locally,
for the specified translation call, by setting
:inflector_lazy_methods option to false.
88 89 90 |
# File 'lib/i18n-inflector-rails/options.rb', line 88 def lazy_methods @lazy_methods end |
#verify_methods ⇒ Object
When this is set to true then
inflection works a bit slower but
checks whether any method exists before
calling it.
This switch is by default set
to false.
By turning this switch on you're sure that
there will be no NameError (no method) exception
raised during translation.
Alternatively you can turn this on locally,
for the specified translation call, by setting
:inflector_verify_methods option to true.
37 38 39 |
# File 'lib/i18n-inflector-rails/options.rb', line 37 def verify_methods @verify_methods end |
Instance Method Details
#reset ⇒ Object
This method resets inflector's switches to default values.
95 96 97 98 99 100 |
# File 'lib/i18n-inflector-rails/options.rb', line 95 def reset @verify_methods = false @auto_helper = true @lazy_methods = true _rai_orig_reset end |