Sha256: 2eed92b82fb4a5dc6f01513d9df5ce353e64382e2752c430ec0229f44ce31167

Contents?: true

Size: 1.05 KB

Versions: 9

Compression:

Stored size: 1.05 KB

Contents

#!/usr/bin/env ruby

puts "Loading MongoModel sandbox..."

begin
  # Try to require the preresolved locked set of gems.
  require File.expand_path('../../.bundle/environment', __FILE__)
rescue LoadError
  # Fall back on doing an unlocked resolve at runtime.
  require "rubygems"
  require "bundler"
  Bundler.setup
end

$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../lib')

require 'irb'
require 'irb/completion'

require 'mongomodel'

IRB.setup(nil)

IRB.conf[:USE_READLINE] = true
IRB.conf[:PROMPT_MODE] = :SIMPLE

irb = IRB::Irb.new

IRB.conf[:MAIN_CONTEXT] = irb.context

examples = <<-EXAMPLES
  
  class Article < MongoModel::Document
    property :title, String, :required => true
    property :published, Boolean, :default => false
    
    timestamps!
    
    default_scope order(:title.asc)
    
    scope :published, where(:published => true)
    scope :latest, lambda { |num| order(:created_at.desc).limit(num) }
  end
  
EXAMPLES

puts examples
irb.context.evaluate(examples, 0)

trap("SIGINT") do
  irb.signal_handle
end
catch(:IRB_EXIT) do
  irb.eval_input
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
mongomodel-0.2.8 bin/console
mongomodel-0.2.7 bin/console
mongomodel-0.2.6 bin/console
mongomodel-0.2.5 bin/console
mongomodel-0.2.4 bin/console
mongomodel-0.2.3 bin/console
mongomodel-0.2.2 bin/console
mongomodel-0.2.1 bin/console
mongomodel-0.2.0 bin/console