Module: Polyseerio::SDK::Static
- Defined in:
- lib/sdk/factory.rb,
lib/sdk/static/find.rb,
lib/sdk/static/check.rb,
lib/sdk/static/index.rb,
lib/sdk/static/attach.rb,
lib/sdk/static/create.rb,
lib/sdk/static/detach.rb,
lib/sdk/static/remove.rb,
lib/sdk/static/update.rb,
lib/sdk/static/execute.rb,
lib/sdk/static/message.rb,
lib/sdk/static/trigger.rb,
lib/sdk/static/find_by_id.rb,
lib/sdk/static/find_by_name.rb
Overview
Static methods.
Constant Summary collapse
- MAP =
Polyseerio::Helper.dir_proc_map(File.dirname(__FILE__), self)
Class Method Summary collapse
- .attach ⇒ Object
- .check ⇒ Object
- .create ⇒ Object
- .detach ⇒ Object
- .execute ⇒ Object
-
.factory(request, resource, statics = [], options = {}) ⇒ Object
Generates static functions.
- .find ⇒ Object
- .find_by_id ⇒ Object
- .find_by_name ⇒ Object
- .message ⇒ Object
- .remove ⇒ Object
- .trigger ⇒ Object
- .update ⇒ Object
Class Method Details
.attach ⇒ Object
5 6 7 8 |
# File 'lib/sdk/static/attach.rb', line 5 def self.attach proc do || end end |
.check ⇒ Object
5 6 7 8 |
# File 'lib/sdk/static/check.rb', line 5 def self.check proc do || end end |
.create ⇒ Object
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/sdk/static/create.rb', line 9 def self.create proc do |request, resource, copts, attributes, = {}| = Polyseerio::Helper.defaults(, copts) eid = Helper.resolve_eid uri = URL.get_resource_path(resource, eid: eid) request.post(uri, attributes) end end |
.detach ⇒ Object
5 6 7 8 |
# File 'lib/sdk/static/detach.rb', line 5 def self.detach proc do || end end |
.execute ⇒ Object
5 6 7 8 |
# File 'lib/sdk/static/execute.rb', line 5 def self.execute proc do || end end |
.factory(request, resource, statics = [], options = {}) ⇒ Object
Generates static functions.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/sdk/factory.rb', line 10 def self.factory(request, resource, statics = [], = {}) accumulator = Helper.accumulate_procs('static', MAP) statics = statics.each_with_object({}, &accumulator) # curry request, resource, and options statics.each_with_object(statics) do |(name, static), hash| if static.arity > 3 hash[name] = static.curry.call(request, resource, ) end end statics end |
.find ⇒ Object
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/sdk/static/find.rb', line 8 def self.find # TODO; issue with arg arity on curry when all optional proc do |request, resource, _copts, _query, = {}| eid = Helper.resolve_eid uri = URL.get_resource_path(resource, eid: eid) # TODO: add query string request.get uri end end |
.find_by_id ⇒ Object
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/sdk/static/find_by_id.rb', line 9 def self.find_by_id proc do |request, resource, copts, id, = {}| = Polyseerio::Helper.defaults(, copts) eid = Helper.resolve_eid uri = URL.get_resource_path(resource, eid: eid, id: id) request.get uri end end |
.find_by_name ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/sdk/static/find_by_name.rb', line 8 def self.find_by_name proc do |request, resource, copts, name, = {}| = Polyseerio::Helper.defaults(, copts) name = "/name/#{name}" eid = Helper.resolve_eid uri = URL.get_resource_path(resource, eid: eid) uri = if resource == Polyseerio::Enum::Resource::ENVIRONMENT "/environments#{name}" else "#{uri}#{name}" end request.get uri end end |
.message ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/sdk/static/message.rb', line 5 def self. proc do |request, resource, _, attributes, | eid = resolve_eid uri = get_resource_path(resource, eid: eid) request.post(uri, attributes) end end |
.remove ⇒ Object
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/sdk/static/remove.rb', line 9 def self.remove proc do |request, resource, copts, id, = {}| = Polyseerio::Helper.defaults(, copts) eid = Helper.resolve_eid uri = URL.get_resource_path(resource, eid: eid, id: id) request.delete uri end end |
.trigger ⇒ Object
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/sdk/static/trigger.rb', line 5 def self.trigger proc do |request, resource, copts, id, payload = {}, = {}| # rubocop:disable all = Polyseerio::Helper.defaults(, copts) eid = Helper.resolve_eid uri = URL.get_resource_path(resource, eid: eid, id: id) request.post("#{uri}/trigger", payload) end end |
.update ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/sdk/static/update.rb', line 5 def self.update # TODO: unit-test proc do |request, resource, copts, id, updates = {}, = {}| # rubocop:disable all = Polyseerio::Helper.defaults(, copts) eid = Helper.resolve_eid uri = URL.get_resource_path(resource, eid: eid, id: id) request.put(uri, updates) end end |