Sha256: 986c0a13edb992972be20a406498a71f248282f29fb9e59c4136ee960396cf94
Contents?: true
Size: 1.75 KB
Versions: 3
Compression:
Stored size: 1.75 KB
Contents
require 'active_record' require 'sqlite3' require 'logger' require 'rspec/rails/adapters' require 'rspec/rails/fixture_support' ROOT = File.join(File.dirname(__FILE__), '..') ActiveRecord::Base.logger = Logger.new('tmp/ar_debug.log') ActiveRecord::Base.configurations = YAML::load(IO.read('spec/support/database.yml')) ActiveRecord::Base.establish_connection('development') ActiveRecord::Schema.define :version => 0 do create_table :ducks, :force => true do |t| t.string :name t.integer :row t.integer :size t.integer :age t.integer :lake_id t.integer :flock_id t.integer :landing_order t.string :pond end create_table :wrong_scope_ducks, :force => true do |t| t.string :name t.integer :size t.string :pond end create_table :wrong_field_ducks, :force => true do |t| t.string :name t.integer :age t.string :pond end create_table :elements, :force => true do |t| t.string :symbol t.string :type t.integer :combination_order end end class Duck < ActiveRecord::Base include RankedModel ranks :row ranks :size, :scope => :in_shin_pond ranks :age, :with_same => :pond ranks :landing_order, :with_same => [:lake_id, :flock_id] scope :in_lake_and_flock, lambda {|lake, flock| where(:lake_id => lake, :flock_id => flock) } scope :in_shin_pond, where(:pond => 'Shin') end # Negative examples class WrongScopeDuck < ActiveRecord::Base include RankedModel ranks :size, :scope => :non_existant_scope end class WrongFieldDuck < ActiveRecord::Base include RankedModel ranks :age, :with_same => :non_existant_field end class Element < ActiveRecord::Base include RankedModel ranks :combination_order end class TransitionMetal < Element end class NobleGas < Element end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
ranked-model-0.1.1 | spec/support/active_record.rb |
ranked-model-0.1.0 | spec/support/active_record.rb |
ranked-model-0.0.5 | spec/support/active_record.rb |