Module: Policy

Defined in:
lib/policy.rb,
lib/policy/version.rb,
lib/policy/follower.rb,
lib/policy/interface.rb,
lib/policy/validations.rb,
lib/policy/follower/names.rb,
lib/policy/violation_error.rb,
lib/policy/follower/followed_policy.rb,
lib/policy/follower/followed_policies.rb

Overview

Policy Object builder

Defined Under Namespace

Modules: Follower, Interface, Validations Classes: ViolationError

Constant Summary collapse

VERSION =

The semantic version of the module.

"1.0.1".freeze

Class Method Summary collapse

Class Method Details

.new(*attributes) ⇒ Struct

Builds a base class for the policy object with some attributes

Examples:

class TransactionPolicy < Policy.new(:debet, :credit)
end

Parameters:

  • attributes (Array<Symbol>)

    names for the policy object attributes

Returns:

  • (Struct)

28
29
30
31
32
33
34
35
36
# File 'lib/policy.rb', line 28

def new(*attributes)
  Struct.new(*attributes) do
    include Interface

    def self.name
      "Policy"
    end
  end
end