Module: Shoppy::Concerns::Models::Optionable
- Extended by:
- ActiveSupport::Concern
- Included in:
- Variant
- Defined in:
- app/models/shoppy/concerns/models/optionable.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
-
#delete_option(key) ⇒ Object
This mothos will delete the key/value pair for the give instance, if the key is founf.
- #empty_option ⇒ Object
-
#put_option(key, value) ⇒ Object
This method will add a key value paid to the model or update the value of the key, if the key is found for a given instance of the model.
Instance Method Details
#delete_option(key) ⇒ Object
This mothos will delete the key/value pair for the give instance, if the key is founf. if not, the command will be ignored.
32 33 34 35 36 |
# File 'app/models/shoppy/concerns/models/optionable.rb', line 32 def delete_option(key) self..delete(key) self. self end |
#empty_option ⇒ Object
38 39 40 41 42 |
# File 'app/models/shoppy/concerns/models/optionable.rb', line 38 def empty_option self. = {} self. self end |
#put_option(key, value) ⇒ Object
This method will add a key value paid to the model or update the value of the key, if the key is found for a given instance of the model
17 18 19 20 21 22 23 24 25 26 27 |
# File 'app/models/shoppy/concerns/models/optionable.rb', line 17 def put_option(key, value) if self.[key] == nil self..merge!({key => value}) unless key == "" self. unless key == "" self else self.[key] = value unless key == "" self. unless key == "" self end end |