Module: HashableParams::ClassMethods

Defined in:
app/models/concerns/hashable_params.rb

Overview

These are shared mothods, a.k.a class methods

Instance Method Summary collapse

Instance Method Details

#by_hash_key(key) ⇒ Object

Query all model instances that have a given key, regardless of the valiue for that key.


44
45
46
# File 'app/models/concerns/hashable_params.rb', line 44

def by_hash_key(key)
	self.where("params_hash ? :key", key: key)
end

#by_hash_key_value(key, value) ⇒ Object

Query all model instance sthat have a given key/value pair.


50
51
52
53
# File 'app/models/concerns/hashable_params.rb', line 50

def by_hash_key_value(key, value)
	kv = key + "=>" + value
	self.where("params_hash @> :kv", kv: kv)
end