Module: ActWithFlags::Base
- Included in:
- ActiveRecord::Base
- Defined in:
- lib/act_with_flags.rb
Instance Attribute Summary collapse
-
#act_with_flags ⇒ Object
readonly
Returns the value of attribute act_with_flags.
Instance Method Summary collapse
- #add_to_flags(*flags, origin: :flags, range: nil, **hash) ⇒ Object
- #clear_flags_at_save ⇒ Object
- #remove_from_flags(*flags) ⇒ Object
Instance Attribute Details
#act_with_flags ⇒ Object (readonly)
Returns the value of attribute act_with_flags.
14 15 16 |
# File 'lib/act_with_flags.rb', line 14 def act_with_flags @act_with_flags end |
Instance Method Details
#add_to_flags(*flags, origin: :flags, range: nil, **hash) ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/act_with_flags.rb', line 16 def add_to_flags(*flags, origin: :flags, range: nil, **hash) origin = origin.to_sym init(origin, range) flags.each { |name| @act_with_flags.add_flag(name, nil, origin) } hash.each { |name, pos| @act_with_flags.add_flag(name, pos, origin) } @act_with_flags end |
#clear_flags_at_save ⇒ Object
30 31 32 |
# File 'lib/act_with_flags.rb', line 30 def clear_flags_at_save(*) @act_with_flags.clear_at_save(*) end |
#remove_from_flags(*flags) ⇒ Object
26 27 28 |
# File 'lib/act_with_flags.rb', line 26 def remove_from_flags(*flags) flags.each { |name| @act_with_flags.remove_accessor(name) } end |