Sha256: 3e518bd0808f5030887f31fc812a06ea58143ca2ef3a12cd7d3ca044ec9770ff

Contents?: true

Size: 1002 Bytes

Versions: 1

Compression:

Stored size: 1002 Bytes

Contents

# frozen_string_literal: true

# Principles:
#  POLA
#  KISS
#  YAGNI
#  POLS
#  DEI
#  TDD considered harmful
#  TGCB

class << ActiveRecord::Base
  attr_reader :act_with_flags

  def add_to_flags(*flags, origin: :flags, **hash)
    unless @act_with_flags
      @act_with_flags ||= ActWithFlags::Admin.new self
      @act_with_flags.add_mask_et_all origin
    end

    flags.each { |name| @act_with_flags.add_flag(name, origin, nil) }
    hash.each { |name, pos| @act_with_flags.add_flag(name, origin, pos) }

    @act_with_flags
  end

  def remove_from_flags(*flags)
    flags.each { |name| @act_with_flags.remove_accessor(name) }
  end

  def clear_flags_at_save(*flags)
    @act_with_flags.clear_at_save(*flags)
  end
end

$LOAD_PATH.unshift(File.join(File.dirname(__FILE__)))
require "act_with_flags/version"
require "act_with_flags/utils"
require "act_with_flags/define"
require "act_with_flags/admin"
require "act_with_flags/flags"
require "act_with_flags/clear"
require "act_with_flags/print"

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
act_with_flags-3.0.1 lib/act_with_flags.rb