Sha256: 6bf4383bb7fb3be9270096dfd65a80ed337d5cafbe0b0ff721cc029e3bfd0e77
Contents?: true
Size: 809 Bytes
Versions: 13
Compression:
Stored size: 809 Bytes
Contents
require 'rubygems' require 'active_record' require 'ar-enums' ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :database => ":memory:") load(File.dirname(__FILE__) + "/../spec/schema.rb") class TrafficLight < ActiveRecord::Base enum :state, %w[red green yellow] end tl = TrafficLight.new(:state => :green) p tl.state # => #<TrafficLight::State @name="green", @id=2> p tl.state_id # => 2 p TrafficLight.states.map(&:to_s) # class TrafficLight < ActiveRecord::Base # enum :state, [ # { :name => :red, :stop_traffic => true, :rgb => 0xF00 }, # { :name => :green, :stop_traffic => false, :rgb => 0x0F0 } # ] # end # # tl = TrafficLight.new(:state => :green) # p tl.state_id # => 2 # p tl.state.stop_traffic # => false # p tl.state.rgb # => 0x0F0
Version data entries
13 entries across 13 versions & 1 rubygems