summaryrefslogtreecommitdiff
path: root/lib/declarative_policy/delegate_dsl.rb
blob: 67e3429b6966253cd84239bb18ff9af99fafa5ec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# frozen_string_literal: true

module DeclarativePolicy
  # Used when the name of a delegate is mentioned in
  # the rule DSL.
  class DelegateDsl
    def initialize(rule_dsl, delegate_name)
      @rule_dsl = rule_dsl
      @delegate_name = delegate_name
    end

    def method_missing(msg, *args)
      return super unless args.empty? && !block_given?

      @rule_dsl.delegate(@delegate_name, msg)
    end
  end
end