Class: FuncE::Func
- Inherits:
-
Object
- Object
- FuncE::Func
- Defined in:
- lib/func_e/func.rb
Overview
Represents a function that can be executed.
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#payload ⇒ Object
readonly
Returns the value of attribute payload.
-
#result ⇒ Object
readonly
Returns the value of attribute result.
-
#run_at ⇒ Object
readonly
Returns the value of attribute run_at.
-
#run_time ⇒ Object
readonly
Returns the value of attribute run_time.
Instance Method Summary collapse
- #exists? ⇒ Boolean
-
#initialize(name) ⇒ Func
constructor
A new instance of Func.
- #path ⇒ Object
- #run(payload) ⇒ Object
- #serialize_payload ⇒ Object
- #set_payload(payload) ⇒ Object
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
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/func_e/func.rb', line 6 def name @name end |
#payload ⇒ Object (readonly)
Returns the value of attribute payload.
6 7 8 |
# File 'lib/func_e/func.rb', line 6 def payload @payload end |
#result ⇒ Object (readonly)
Returns the value of attribute result.
6 7 8 |
# File 'lib/func_e/func.rb', line 6 def result @result end |
#run_at ⇒ Object (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_time ⇒ Object (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
35 36 37 |
# File 'lib/func_e/func.rb', line 35 def exists? File.exist?(@path) end |
#path ⇒ Object
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_payload ⇒ Object
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 |