Sha256: 8b494e311656c3ded67433eda08d06edba9e323e64377adbfd2b5cdc06620fef
Contents?: true
Size: 651 Bytes
Versions: 6
Compression:
Stored size: 651 Bytes
Contents
module Troo module ModelHelpers module ClassMethods def first(criteria = {}) return all.first if criteria.nil? || criteria.empty? find(criteria).first end def update(criteria = {}) return false if criteria.nil? || criteria.empty? all.map { |record| record.update(criteria) } true end def default first(default: true) end def count all.count end end def self.included(base) base.extend(ClassMethods) end def external_attributes self.attributes.delete_if { |k, _| k == :id || k == :default } end end end
Version data entries
6 entries across 6 versions & 1 rubygems