Module: HashableParams

Extended by:
ActiveSupport::Concern
Included in:
Edition
Defined in:
app/models/concerns/hashable_params.rb

Overview

app/models/conerns/hashable.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#delete_hash(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.


33
34
35
36
37
# File 'app/models/concerns/hashable_params.rb', line 33

def delete_hash(key)
	self.params_hash.delete(key)
	self.params_hash_will_change!
	self
end

#put_hash(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


18
19
20
21
22
23
24
25
26
27
28
# File 'app/models/concerns/hashable_params.rb', line 18

def put_hash(key, value)
	if self.params_hash[key] == nil
		self.params_hash.merge!({key => value})
		self.params_hash_will_change!
		self
	else
		self.params_hash[key] = value
		self.params_hash_will_change!
		self
	end
end