Class: ActionHandler::Call

Inherits:
Object
  • Object
show all
Defined in:
lib/action_handler/call.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(method_name, args = []) ⇒ Call

Returns a new instance of Call.

Raises:

  • (ArgumentError)


8
9
10
11
12
13
# File 'lib/action_handler/call.rb', line 8

def initialize(method_name, args = [])
  raise ArgumentError, 'args must be an array' unless args.is_a?(Array)

  @method_name = method_name.to_sym
  @args = args.freeze
end

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args.



6
7
8
# File 'lib/action_handler/call.rb', line 6

def args
  @args
end

#method_nameObject (readonly)

Returns the value of attribute method_name.



5
6
7
# File 'lib/action_handler/call.rb', line 5

def method_name
  @method_name
end

Instance Method Details

#==(other) ⇒ Object

overrides



20
21
22
23
24
# File 'lib/action_handler/call.rb', line 20

def ==(other)
  other.is_a?(ActionHandler::Call) &&
    method_name == other.method_name &&
    args == other.args
end

#call_with(receiver) ⇒ Object



15
16
17
# File 'lib/action_handler/call.rb', line 15

def call_with(receiver)
  receiver.send(method_name, *args)
end

#hashObject

overrides



27
28
29
# File 'lib/action_handler/call.rb', line 27

def hash
  [method_name, args].hash
end