Sha256: 3a5a8a539848e439eb7e2e529dd6117351323ce0e5b0c81ef1e9093a37127027
Contents?: true
Size: 749 Bytes
Versions: 6
Compression:
Stored size: 749 Bytes
Contents
module Counter::Conditional extend ActiveSupport::Concern included do def increment? item, on accept_item? item, on, increment: true end def decrement? item, on accept_item? item, on, increment: false end def accept_item? item, on, increment: true return true unless definition.conditional? conditions = definition.conditions[on] return true unless conditions conditions.any? do |conditions| if increment conditions.increment_conditions.any? do |condition| condition.call(item) end else conditions.decrement_conditions.any? do |condition| condition.call(item) end end end end end end
Version data entries
6 entries across 6 versions & 1 rubygems