Module: ActiveScaffold::MarkedModel
- Defined in:
- lib/active_scaffold/marked_model.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
-
.included(base) ⇒ Object
This is a module aimed at making the make session_stored marked_records available to ActiveRecord models.
Instance Method Summary collapse
-
#as_marked ⇒ Object
rubocop:disable Naming/PredicateMethod.
- #as_marked=(value) ⇒ Object
Class Method Details
.included(base) ⇒ Object
This is a module aimed at making the make session_stored marked_records available to ActiveRecord models
7 8 9 10 11 12 13 |
# File 'lib/active_scaffold/marked_model.rb', line 7 def self.included(base) base.class_eval do extend ClassMethods scope :as_marked, -> { where(primary_key => marked_record_ids) } end end |
Instance Method Details
#as_marked ⇒ Object
rubocop:disable Naming/PredicateMethod
15 16 17 |
# File 'lib/active_scaffold/marked_model.rb', line 15 def as_marked # rubocop:disable Naming/PredicateMethod marked_records.include?(id.to_s) end |
#as_marked=(value) ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/active_scaffold/marked_model.rb', line 19 def as_marked=(value) if [true, 'true', 1, '1', 'T', 't'].include?(value.respond_to?(:downcase) ? value.downcase : value) marked_records[id.to_s] = true unless as_marked else marked_records.delete(id.to_s) end end |