Class: Itly::Options
- Inherits:
-
Object
- Object
- Itly::Options
- Defined in:
- lib/itly/options.rb,
lib/itly/options/validation.rb,
lib/itly/options/environment.rb
Overview
Options class for Itly object initialization
Defined Under Namespace
Modules: Environment, Validation
Instance Attribute Summary collapse
-
#disabled ⇒ Object
Returns the value of attribute disabled.
-
#environment ⇒ Object
Returns the value of attribute environment.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#on_validation_error ⇒ Object
Returns the value of attribute on_validation_error.
-
#plugins ⇒ Object
Returns the value of attribute plugins.
-
#validation ⇒ Itly::Options::Validation
Return the current validation behavior.
Instance Method Summary collapse
- #development? ⇒ Boolean
-
#for_plugin ⇒ Itly::PluginOptions
Returns the options that are passed to plugin #load.
-
#initialize(environment: Itly::Options::Environment::DEVELOPMENT, disabled: false, plugins: [], validation: nil, logger: nil, on_validation_error: nil) ⇒ Options
constructor
Create a new Options object with default values.
- #production? ⇒ Boolean
Constructor Details
#initialize(environment: Itly::Options::Environment::DEVELOPMENT, disabled: false, plugins: [], validation: nil, logger: nil, on_validation_error: nil) ⇒ Options
Create a new Options object with default values
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/itly/options.rb', line 59 def initialize( environment: Itly::Options::Environment::DEVELOPMENT, disabled: false, plugins: [], validation: nil, logger: nil, on_validation_error: nil ) @environment = environment @disabled = disabled @plugins = plugins @validation = validation @logger = logger @on_validation_error = on_validation_error end |
Instance Attribute Details
#disabled ⇒ Object
Returns the value of attribute disabled.
53 54 55 |
# File 'lib/itly/options.rb', line 53 def disabled @disabled end |
#environment ⇒ Object
Returns the value of attribute environment.
53 54 55 |
# File 'lib/itly/options.rb', line 53 def environment @environment end |
#logger ⇒ Object
Returns the value of attribute logger.
53 54 55 |
# File 'lib/itly/options.rb', line 53 def logger @logger end |
#on_validation_error ⇒ Object
Returns the value of attribute on_validation_error.
53 54 55 |
# File 'lib/itly/options.rb', line 53 def on_validation_error @on_validation_error end |
#plugins ⇒ Object
Returns the value of attribute plugins.
53 54 55 |
# File 'lib/itly/options.rb', line 53 def plugins @plugins end |
#validation ⇒ Itly::Options::Validation
Return the current validation behavior
89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/itly/options.rb', line 89 def validation if @validation.nil? if development? Itly::Options::Validation::ERROR_ON_INVALID else Itly::Options::Validation::TRACK_INVALID end else @validation end end |
Instance Method Details
#development? ⇒ Boolean
16 17 18 |
# File 'lib/itly/options/environment.rb', line 16 def development? @environment == Itly::Options::Environment::DEVELOPMENT end |
#for_plugin ⇒ Itly::PluginOptions
Returns the options that are passed to plugin #load
80 81 82 |
# File 'lib/itly/options.rb', line 80 def for_plugin ::Itly::PluginOptions.new environment: environment, logger: logger end |
#production? ⇒ Boolean
20 21 22 |
# File 'lib/itly/options/environment.rb', line 20 def production? @environment == Itly::Options::Environment::PRODUCTION end |