Class: Invokr::Invocation

Inherits:
Struct
  • Object
show all
Defined in:
lib/invokr/invocation.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#block_argObject

Returns the value of attribute block_arg

Returns:

  • (Object)

    the current value of block_arg



2
3
4
# File 'lib/invokr/invocation.rb', line 2

def block_arg
  @block_arg
end

#keyword_argsObject

Returns the value of attribute keyword_args

Returns:

  • (Object)

    the current value of keyword_args



2
3
4
# File 'lib/invokr/invocation.rb', line 2

def keyword_args
  @keyword_args
end

#methodObject

Returns the value of attribute method

Returns:

  • (Object)

    the current value of method



2
3
4
# File 'lib/invokr/invocation.rb', line 2

def method
  @method
end

#positional_argsObject

Returns the value of attribute positional_args

Returns:

  • (Object)

    the current value of positional_args



2
3
4
# File 'lib/invokr/invocation.rb', line 2

def positional_args
  @positional_args
end

Instance Method Details

#argsObject



15
16
17
18
19
# File 'lib/invokr/invocation.rb', line 15

def args
  args = positional_args.dup
  args << keyword_args unless keyword_args.empty?
  args
end

#block_arg?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/invokr/invocation.rb', line 11

def block_arg?
  block_arg ? true : false
end

#invoke!(obj) ⇒ Object



3
4
5
6
7
8
9
# File 'lib/invokr/invocation.rb', line 3

def invoke! obj
  if block_arg?
    obj.public_send method, *args, &block_arg
  else
    obj.public_send method, *args
  end
end