Sha256: 4f1b3d27242e2c19e5545f7443d95a315b151c5308eb76c8231e23858621c113
Contents?: true
Size: 1.25 KB
Versions: 5
Compression:
Stored size: 1.25 KB
Contents
## # MongoMapper adapter to ExtJS::Model mixin # module ExtJS module Model ## # ClassMethods # module ClassMethods def extjs_primary_key :_id end def extjs_column_names self.column_names end def extjs_columns_hash self.keys end def extjs_associations @extjs_associations ||= self.associations.inject({}) do |memo, (key, assn)| memo[key.to_sym] = { :name => key.to_sym, :type => assn.type, :class => assn.class_name.constantize, :foreign_key => assn.foreign_key, :is_polymorphic => false } memo end end def extjs_type(col) type = col.type.to_s case type when "DateTime", "Date", "Time" type = :date when "String" type = :string when "Float" type = :float when "Integer", "BigDecimal" type = :int else type = "auto" end end def extjs_allow_blank(col) (col.name == '_id') || (col.options[:required] != true) end def extjs_default(col) col.default_value end end end end
Version data entries
5 entries across 5 versions & 1 rubygems