Class: TimePricing::Config
- Inherits:
-
Object
- Object
- TimePricing::Config
- Defined in:
- lib/time_pricing/config.rb
Instance Attribute Summary collapse
-
#cache ⇒ Object
Returns the value of attribute cache.
-
#combine_plans ⇒ Object
Returns the value of attribute combine_plans.
-
#plans ⇒ Object
Returns the value of attribute plans.
Instance Method Summary collapse
- #add_plan!(**args) ⇒ Object
- #clear_cache! ⇒ Object
- #combine_plans? ⇒ Boolean
-
#initialize(**args) ⇒ Config
constructor
A new instance of Config.
- #remove_plan!(name) ⇒ Object
Constructor Details
#initialize(**args) ⇒ Config
Returns a new instance of Config.
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/time_pricing/config.rb', line 5 def initialize(**args) @combine_plans = args[:combine_plans] || args[:combine_plans] == nil @plans = {} if args[:cache].is_a?(Hash) @cache = args[:cache] else @cache = {} end end |
Instance Attribute Details
#cache ⇒ Object
Returns the value of attribute cache.
3 4 5 |
# File 'lib/time_pricing/config.rb', line 3 def cache @cache end |
#combine_plans ⇒ Object
Returns the value of attribute combine_plans.
3 4 5 |
# File 'lib/time_pricing/config.rb', line 3 def combine_plans @combine_plans end |
#plans ⇒ Object
Returns the value of attribute plans.
3 4 5 |
# File 'lib/time_pricing/config.rb', line 3 def plans @plans end |
Instance Method Details
#add_plan!(**args) ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/time_pricing/config.rb', line 21 def add_plan!(**args) plan = Plan.new(args) # clear cache as plans change clear_cache! @plans[plan.name] = plan end |
#clear_cache! ⇒ Object
17 18 19 |
# File 'lib/time_pricing/config.rb', line 17 def clear_cache! @cache = {} end |
#combine_plans? ⇒ Boolean
36 37 38 |
# File 'lib/time_pricing/config.rb', line 36 def combine_plans? @combine_plans end |
#remove_plan!(name) ⇒ Object
30 31 32 33 34 |
# File 'lib/time_pricing/config.rb', line 30 def remove_plan!(name) # clear cache as plans change clear_cache! @plans.delete(name) end |