Sha256: d1b800d81637b4a0e1ae03436fe4b88529a645244bdb82bb9fd6ecec43d10cb0
Contents?: true
Size: 1.6 KB
Versions: 3
Compression:
Stored size: 1.6 KB
Contents
require 'spiderfw/model/base_model' module Spider; module Model # The main superclass of non-legacy models. # Extends the BaseModel providing an autoincrementing id and creation/modification timestamps. # Defines the following elements: # element :id, Fixnum, :primary_key => true,:autoincrement => true, :read_only => true, :element_position => 0} # element :obj_created, DateTime, :hidden => true # element :obj_modified, DateTime, :hidden => true # # Other modules may be mixed-in to add default functionality to managed models. class Managed < BaseModel element :id, Fixnum, { :primary_key => true, :autoincrement => true, :read_only => true, :element_position => 0 } element :obj_created, DateTime, :label => _('Created'), :hidden => true element :obj_modified, DateTime, :label => _('Modified'), :hidden => true def assign_id(val) #:nodoc: @id = val end def self.managed? true end def _set_dates(bool=nil) @_set_dates = true if @_set_dates == nil @_set_dates = bool if bool != nil @_set_dates end with_mapper do def before_save(obj, mode) if obj._set_dates obj.obj_created = DateTime.now if mode == :insert obj.obj_modified = DateTime.now if obj.modified? end super end end end end; end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
spiderfw-0.5.13 | lib/spiderfw/model/extended_models/managed.rb |
spiderfw-0.5.12 | lib/spiderfw/model/extended_models/managed.rb |
spiderfw-0.5.11 | lib/spiderfw/model/extended_models/managed.rb |