Sha256: 286d2b08eb6b0f6932bfb6c82e4fdae405a00c3339b97cf85881693112902e3d
Contents?: true
Size: 1.05 KB
Versions: 1
Compression:
Stored size: 1.05 KB
Contents
module ActiveScaffold module MarkedModel # This is a module aimed at making the make session_stored marked_records available to ActiveRecord models def self.included(base) base.extend ClassMethods base.scope :marked, lambda {{:conditions => {:id => base.marked_records.to_a}}} end def marked marked_records.include?(self.id) end def marked=(value) value = [true, 'true', 1, '1', 'T', 't'].include?(value.class == String ? value.downcase : value) if value == true marked_records << self.id if !marked else marked_records.delete(self.id) end end module ClassMethods # The proc to call that retrieves the marked_records from the ApplicationController. attr_accessor :marked_records_proc # Class-level access to the marked_records def marked_records (marked_records_proc.call || Set.new) if marked_records_proc end end # Instance-level access to the marked_records def marked_records self.class.marked_records end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
active_scaffold-3.0.5 | lib/active_scaffold/marked_model.rb |