Sha256: 0aedb0c3f395a201edf3ec450b53415f34b871e685384b4d9394e8fd04be015e

Contents?: true

Size: 1009 Bytes

Versions: 16

Compression:

Stored size: 1009 Bytes

Contents

class AppModel2
  include ::Mongoid::Document
  include ::Mongoid::Timestamps

  field :is_feature, :type => Boolean, :default => false
  field :is_public, :type => Boolean, :default => true
  field :is_done, :type => Boolean, :default => false
  field :is_trash, :type => Boolean, :default => false
  field :is_anonymous, :type => Boolean, :default => false

  scope :fresh, ->{ where({ :is_trash => false }) }
  scope :trash, ->{ where({ :is_trash => true }) }
  scope :public, ->{ where({ :is_public => true }) }
  scope :done, ->{ where({ :is_done => true }) }

  default_scope ->{ where({ :is_public => true, :is_trash => false }).order_by({ :created_at => :desc }) }
  
  field :x, :type => Float
  field :y, :type => Float

  def self.list conditions = { :is_trash => false }
    out = self.where( conditions).order_by( :name => :asc )
    [['', nil]] + out.map { |item| [ item.name, item.id ] }
  end

  private

  def puts! arg, label=""
    puts "+++ +++ #{label}"
    puts arg.inspect
  end
  
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
ish_models-0.0.33.14 lib/app_model2.rb
ish_models-0.0.33.13 lib/app_model2.rb
ish_models-0.0.33.12 lib/app_model2.rb
ish_models-0.0.33.11 lib/app_model2.rb
ish_models-0.0.33.10 lib/app_model2.rb
ish_models-0.0.33.8 lib/app_model2.rb
ish_models-0.0.33.7 lib/app_model2.rb
ish_models-0.0.33.6 lib/app_model2.rb
ish_models-0.0.33.5 lib/app_model2.rb
ish_models-0.0.33 lib/app_model2.rb
ish_models-0.0.32 lib/app_model2.rb
ish_models-0.0.31 lib/app_model2.rb
ish_models-0.0.30 lib/app_model2.rb
ish_models-0.0.29.10 lib/app_model2.rb
ish_models-0.0.29.9 lib/app_model2.rb
ish_models-0.0.6 lib/app_model2.rb