Class: Xaases::Aws::LambdaJs
- Inherits:
-
Object
- Object
- Xaases::Aws::LambdaJs
- Defined in:
- lib/xaases/aws/lambda_js.rb
Instance Attribute Summary collapse
-
#minify ⇒ Object
readonly
Returns the value of attribute minify.
Instance Method Summary collapse
- #dynamo_put(table, data, handler) ⇒ Object
- #export(name, content) ⇒ Object
-
#initialize(minify: true) ⇒ LambdaJs
constructor
A new instance of LambdaJs.
- #render ⇒ Object
- #res(status, content) ⇒ Object
- #use_dynamo! ⇒ Object
Constructor Details
Instance Attribute Details
#minify ⇒ Object (readonly)
Returns the value of attribute minify.
5 6 7 |
# File 'lib/xaases/aws/lambda_js.rb', line 5 def minify @minify end |
Instance Method Details
#dynamo_put(table, data, handler) ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/xaases/aws/lambda_js.rb', line 31 def dynamo_put(table, data, handler) params = { 'TableName' => "'#{table}'", 'Item' => Xaases::Js.new(minify: minify).hash(data) } params_js = Xaases::Js.new(minify: minify).hash(params) @js.call 'dyn.put', params_js, handler end |
#export(name, content) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/xaases/aws/lambda_js.rb', line 18 def export(name, content) #f = Xaases::Js::Function.new(:eve, :ctx, :cb) f = Xaases::Js::Function.new(:event, :context, :callback) f.content = content @js.export(name, f) end |
#render ⇒ Object
40 41 42 |
# File 'lib/xaases/aws/lambda_js.rb', line 40 def render @js.render end |
#res(status, content) ⇒ Object
25 26 27 28 29 |
# File 'lib/xaases/aws/lambda_js.rb', line 25 def res(status, content) #err = err ? err : 'null' body = Xaases::Js.new(minify: minify).hash('statusCode' => status, 'body' => content) @js.call :callback, 'null', body end |
#use_dynamo! ⇒ Object
14 15 16 |
# File 'lib/xaases/aws/lambda_js.rb', line 14 def use_dynamo! @js.const(dyn: 'new aws.DynamoDB()') end |