Sha256: 407ac483f4fd9d0c58cb8ad16ed61def376fcc73b5b760da90072c139f0eebd3
Contents?: true
Size: 1.57 KB
Versions: 3
Compression:
Stored size: 1.57 KB
Contents
## # MongoMapper adapter to ExtJS::Model mixin # module ExtJS module Model module InstanceMethods def extjs_prepare_data(pk) {pk => self.send(pk).to_s} end end ## # 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 if @extjs_associations.nil? @extjs_associations = {} self.associations.keys.each do |key| @extjs_associations[key.to_sym] = { :name => key, :type => self.associations[key].type, :class => self.associations[key].class_name.constantize, :foreign_key => self.associations[key].foreign_key, :is_polymorphic => false # <-- no impl. for MM is_polymorhpic yet. Anyone care to implement this? } end end @extjs_associations 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
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
extjs-mvc-0.3.4 | lib/model/mongo_mapper.rb |
extjs-mvc-0.3.3 | lib/model/mongo_mapper.rb |
extjs-mvc-0.3.2 | lib/model/mongo_mapper.rb |