Module: StateGate::Builder::ScopeMethods

Included in:
StateGate::Builder
Defined in:
lib/state_gate/builder/scope_methods.rb

Overview

Description

Multiple private methods enabling StateGate::Builder to generate scopes for each state.

  • fetch all records with the given state:

    Klass.active #=> Klass.where(state: :active)
    
  • fetch all records without the given state:

    Klass.not_active #=> Klass.where.not(state: :active)
    
  • fetch all records with the supplied states:

    Klass.with_statuses(:pending, :active) #=> Klass.where(state: [:pending, :active])