Class: Granite::Action::Precondition

Inherits:
BasicObject
Defined in:
lib/granite/action/precondition.rb

Constant Summary collapse

UNDEFINED =
::Object.new.freeze

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(context) ⇒ Precondition

Returns a new instance of Precondition.



15
16
17
# File 'lib/granite/action/precondition.rb', line 15

def initialize(context)
  @context = context
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args, &blk) ⇒ Object



23
24
25
26
27
# File 'lib/granite/action/precondition.rb', line 23

def method_missing(method_name, *args, &blk)
  super unless @context.respond_to?(method_name)

  @context.__send__(method_name, *args, &blk)
end

Class Method Details

.description(text = UNDEFINED) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/granite/action/precondition.rb', line 6

def self.description(text = UNDEFINED)
  case text
  when UNDEFINED
    @description
  else
    @description = text
  end
end

Instance Method Details

#callObject



19
20
21
# File 'lib/granite/action/precondition.rb', line 19

def call(*)
  fail NotImplementedError, "#call method must be implemented for #{self.class}"
end

#respond_to_missing?(method_name, _include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/granite/action/precondition.rb', line 29

def respond_to_missing?(method_name, _include_private = false)
  @context.respond_to?(method_name)
end