File: delegate_dsl.rb

package info (click to toggle)
ruby-declarative-policy 1.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 264 kB
  • sloc: ruby: 1,020; makefile: 4
file content (22 lines) | stat: -rw-r--r-- 485 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# 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

    def respond_to_missing?(msg, include_all)
      true
    end
  end
end