Module: Weesked::Configuration
- Included in:
- Weesked
- Defined in:
- lib/weesked/configuration.rb
Constant Summary collapse
- VALID_OPTIONS_KEYS =
[ :time_step, :availiable_days, :availiable_steps, :steps_day_shift, # :redis ].freeze
- DEFAULT_TIME_STEP =
By default, 1.hour
SECONDS_IN_HOUR- DEFAULT_AVAILIABLE_DAYS =
By default, the whole week
%w(sunday monday tuesday wednesday thursday friday saturday)
- DEFAULT_AVAILIABLE_STEPS =
By default, whole day in hours
(0..23).to_a
- DEFAULT_STEPS_DAY_SHIFT =
By default, we use astonomical day
0
Class Method Summary collapse
-
.extended(base) ⇒ Object
When this module is extended, set all configuration options to their default values.
Instance Method Summary collapse
-
#configure {|_self| ... } ⇒ Object
Convenience method to allow configuration options to be set in a block.
-
#options ⇒ Object
Create a hash of options and their values.
-
#reset ⇒ Object
Reset all configuration options to defaults.
Class Method Details
.extended(base) ⇒ Object
When this module is extended, set all configuration options to their default values
35 36 37 |
# File 'lib/weesked/configuration.rb', line 35 def self.extended(base) base.reset end |
Instance Method Details
#configure {|_self| ... } ⇒ Object
Convenience method to allow configuration options to be set in a block
40 41 42 |
# File 'lib/weesked/configuration.rb', line 40 def configure yield self end |
#options ⇒ Object
Create a hash of options and their values
45 46 47 48 49 |
# File 'lib/weesked/configuration.rb', line 45 def VALID_OPTIONS_KEYS.inject({}) do |option, key| option.merge!(key => send(key)) end end |
#reset ⇒ Object
Reset all configuration options to defaults
52 53 54 55 56 57 |
# File 'lib/weesked/configuration.rb', line 52 def reset self.time_step = DEFAULT_TIME_STEP self.availiable_days = DEFAULT_AVAILIABLE_DAYS self.availiable_steps = DEFAULT_AVAILIABLE_STEPS self.steps_day_shift = DEFAULT_STEPS_DAY_SHIFT end |