Module: Troo::ModelHelpers::ClassMethods
- Defined in:
- lib/troo/models/model_helpers.rb
Instance Method Summary collapse
Instance Method Details
#count ⇒ Object
19 20 21 |
# File 'lib/troo/models/model_helpers.rb', line 19 def count all.count end |
#default ⇒ Object
15 16 17 |
# File 'lib/troo/models/model_helpers.rb', line 15 def default first(default: true) end |
#first(criteria = {}) ⇒ Object
4 5 6 7 |
# File 'lib/troo/models/model_helpers.rb', line 4 def first(criteria = {}) return all.first if criteria.nil? || criteria.empty? find(criteria).first end |
#update(criteria = {}) ⇒ Object
9 10 11 12 13 |
# File 'lib/troo/models/model_helpers.rb', line 9 def update(criteria = {}) return false if criteria.nil? || criteria.empty? all.map { |record| record.update(criteria) } true end |