Class: DeclarativePolicy::DelegateDsl

Inherits:
Object
  • Object
show all
Defined in:
lib/declarative_policy/delegate_dsl.rb

Overview

Used when the name of a delegate is mentioned in the rule DSL.

Instance Method Summary collapse

Constructor Details

#initialize(rule_dsl, delegate_name) ⇒ DelegateDsl

Returns a new instance of DelegateDsl.



7
8
9
10
# File 'lib/declarative_policy/delegate_dsl.rb', line 7

def initialize(rule_dsl, delegate_name)
  @rule_dsl = rule_dsl
  @delegate_name = delegate_name
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(msg, *args) ⇒ Object



12
13
14
15
16
# File 'lib/declarative_policy/delegate_dsl.rb', line 12

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

  @rule_dsl.delegate(@delegate_name, msg)
end

Instance Method Details

#respond_to_missing?(msg, include_all) ⇒ Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/declarative_policy/delegate_dsl.rb', line 18

def respond_to_missing?(msg, include_all)
  true
end