class Object
Public Instance Methods
cat_fields()
click to toggle source
# File lib/dm-is-reflective/test.rb, line 89 def cat_fields @cat_fields ||= [[:id, DataMapper::Property::Serial, {:unique_index => :abstract_cats_pkey}.merge(AttrCommonPK)], [:super_user_id, Integer, {:unique_index => :unique_abstract_cats_usu, :index => :index_abstract_cats_su }.merge(AttrCommon)], [:user_id , Integer, {:unique_index => [:unique_abstract_cats_usu, :unique_abstract_cats_u]}.merge(AttrCommon)]] end
cat_indices()
click to toggle source
# File lib/dm-is-reflective/test.rb, line 72 def cat_indices @cat_indices ||= begin id = case DataMapper.repository.adapter.class.name when 'DataMapper::Adapters::SqliteAdapter' nil else [:id, {:unique_index => :abstract_cats_pkey, :key => true}] end [id , [:super_user_id, {:unique_index => :unique_abstract_cats_usu , :index => :index_abstract_cats_su }] , [ :user_id, {:unique_index => [:unique_abstract_cats_usu , :unique_abstract_cats_u]}] ]. compact end end
comment_fields()
click to toggle source
# File lib/dm-is-reflective/test.rb, line 101 def comment_fields @comment_fields ||= begin [[:body , DataMapper::Property::Text , AttrText], [:id , DataMapper::Property::Serial, {:unique_index => :abstract_comments_pkey}.merge(AttrCommonPK)], [:title , String , {:length => 50, :default => 'default title', :allow_nil => false}], [:user_id, Integer , {:index => :index_abstract_comments_user}.merge(AttrCommon)]] end end
create_fake_model()
click to toggle source
# File lib/dm-is-reflective/test.rb, line 147 def create_fake_model model = Class.new model.module_eval do include DataMapper::Resource property :id, DataMapper::Property::Serial is :reflective end Abstract.const_set("Model#{Abstract.next_id}", model) [model, setup_data_mapper] end
new_scope()
click to toggle source
# File lib/dm-is-reflective/test.rb, line 158 def new_scope Abstract.const_set("Scope#{Abstract.next_id}", Module.new) end
sort_fields(fields)
click to toggle source
# File lib/dm-is-reflective/test.rb, line 143 def sort_fields fields fields.sort_by{ |f| f.first.to_s } end
super_user_fields()
click to toggle source
# File lib/dm-is-reflective/test.rb, line 124 def super_user_fields @super_user_fields ||= begin type = case DataMapper.repository.adapter.class.name when 'DataMapper::Adapters::MysqlAdapter' Integer else DataMapper::Property::Boolean end [[:bool, type, AttrCommon], [:id , DataMapper::Property::Serial, {:unique_index => :abstract_super_users_pkey}.merge(AttrCommonPK)]] end end
test_create_comment()
click to toggle source
# File lib/dm-is-reflective/test.rb, line 162 def test_create_comment Comment.create(:title => 'XD') Comment.first.title.should.eq 'XD' end
test_create_user()
click to toggle source
# File lib/dm-is-reflective/test.rb, line 167 def test_create_user now = Time.now User.create(:created_at => now) User.first.created_at.asctime.should.eq now.asctime now end
user_fields()
click to toggle source
# File lib/dm-is-reflective/test.rb, line 115 def user_fields @user_fields ||= [[:created_at, DateTime, AttrCommon], [:id, DataMapper::Property::Serial, {:unique_index => :abstract_users_pkey}.merge(AttrCommonPK)], [:login, String, {:length => 70}.merge(AttrCommon)], [:sig, DataMapper::Property::Text, AttrText]] end