Sha256: b1a4b38cc7989235ff4c033de85be589174019ce357ff53a7819b6a78a830e4c

Contents?: true

Size: 905 Bytes

Versions: 1

Compression:

Stored size: 905 Bytes

Contents

module DmIsReflective::SqliteAdapterPatch
  def reflective_lookup_primitive primitive
    case primitive.upcase
    when 'INTEGER' ; Integer
    when 'REAL', 'NUMERIC', 'FLOAT'; Float
    when 'VARCHAR' ; String
    when 'TIMESTAMP' ; DateTime
    when 'BOOLEAN' ; Property::Boolean
    when 'TEXT' ; Property::Text
    else Property::Text
    end || super(primitive)
  end
end


module DmIsReflective::ClassMethod
  def to_source scope=nil

    <<-RUBY
class #{scope}::#{name} < #{superclass}
include DataMapper::Resource
#{
properties.map do |prop|
    hash = prop.options.dup
    hash.delete :scale if hash.include? :scale and hash[:scale].nil?
    "property :#{prop.name}, #{prop.class.name}, #{hash}"
end.join("\n")
}
end
RUBY
  end  
end

DataMapper::Adapters.const_get("SqliteAdapter").__send__(:include,
     DmIsReflective::SqliteAdapterPatch)
DataMapper::Model.append_extensions(DmIsReflective)

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
clearest-0.0.1a lib/clearest/patches/1_sqlite_adapter_patch.rb