Sha256: 4b83ffd120cc560cb46bf07c3566801d5a81e8c3215e9dc58694baaa37ca3ff9
Contents?: true
Size: 1.04 KB
Versions: 2
Compression:
Stored size: 1.04 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.named_scope :marked, lambda {{:conditions => {:id => base.marked_records.to_a}}} end def marked marked_records.include?(self.id) end def marked=(value) value = (value.downcase == 'true') if value.is_a? String 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
brisk-bills-0.8.2 | vendor/plugins/active_scaffold/lib/active_scaffold/marked_model.rb |
brisk-bills-0.8.1 | vendor/plugins/active_scaffold/lib/active_scaffold/marked_model.rb |