Class: FuncE::Func

Inherits:
Object
  • Object
show all
Defined in:
lib/func_e/func.rb

Overview

Represents a function that can be executed.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Func

Returns a new instance of Func.



8
9
10
11
# File 'lib/func_e/func.rb', line 8

def initialize(name)
  @name = name
  @path = path
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



6
7
8
# File 'lib/func_e/func.rb', line 6

def name
  @name
end

#payloadObject (readonly)

Returns the value of attribute payload.



6
7
8
# File 'lib/func_e/func.rb', line 6

def payload
  @payload
end

#resultObject (readonly)

Returns the value of attribute result.



6
7
8
# File 'lib/func_e/func.rb', line 6

def result
  @result
end

#run_atObject (readonly)

Returns the value of attribute run_at.



6
7
8
# File 'lib/func_e/func.rb', line 6

def run_at
  @run_at
end

#run_timeObject (readonly)

Returns the value of attribute run_time.



6
7
8
# File 'lib/func_e/func.rb', line 6

def run_time
  @run_time
end

Instance Method Details

#exists?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/func_e/func.rb', line 35

def exists?
  File.exist?(@path)
end

#pathObject



13
14
15
# File 'lib/func_e/func.rb', line 13

def path
  FuncE::Config.install_path.join("#{@name}.js")
end

#run(payload) ⇒ Object



17
18
19
20
21
22
23
24
25
# File 'lib/func_e/func.rb', line 17

def run(payload)
  @payload = payload

  benchmark do
    @result = FuncE.exec(self)
  end

  @result
end

#serialize_payloadObject



31
32
33
# File 'lib/func_e/func.rb', line 31

def serialize_payload
  @payload.to_json
end

#set_payload(payload) ⇒ Object



27
28
29
# File 'lib/func_e/func.rb', line 27

def set_payload(payload)
  @payload = payload
end