module ActiveScaffold::MarkedModel

Public Instance Methods

as_marked() click to toggle source
# File lib/active_scaffold/marked_model.rb, line 10
def as_marked
  marked_records.include?(self.id)
end
as_marked=(value) click to toggle source
# File lib/active_scaffold/marked_model.rb, line 14
def as_marked=(value)
  value = [true, 'true', 1, '1', 'T', 't'].include?(value.class == String ? value.downcase : value)
  if value == true
    marked_records << self.id if !as_marked
  else
    marked_records.delete(self.id)
  end
end
marked_records() click to toggle source

Instance-level access to the #marked_records

# File lib/active_scaffold/marked_model.rb, line 34
def marked_records
  self.class.marked_records
end

Public Class Methods

included(base) click to toggle source

This is a module aimed at making the make session_stored #marked_records available to ActiveRecord models

# File lib/active_scaffold/marked_model.rb, line 5
def self.included(base)
  base.extend ClassMethods
  base.scope :as_marked, lambda { where(:id => base.marked_records.to_a) }
end