Sha256: 97333795e66a106f9591ed2a33c67f9f0143ea7ff79e62dd639aa28603ca7207
Contents?: true
Size: 545 Bytes
Versions: 8
Compression:
Stored size: 545 Bytes
Contents
module Hancock::BooleanField extend ActiveSupport::Concern module ClassMethods def boolean_field(name, default = true) if default.is_a?(Hash) default = default[:default] end if Hancock.mongoid? field name, type: Mongoid::Boolean, default: default end scope name, -> { where(name => true) } if name == 'active' scope :inactive, -> { where(active: false) } elsif name == 'enabled' scope :disabled, -> { where(enabled: false) } end end end end
Version data entries
8 entries across 8 versions & 1 rubygems