Class: ForestLiana::Collection

Inherits:
Object
  • Object
show all
Defined in:
app/services/forest_liana/collection.rb

Class Method Summary collapse

Class Method Details

.action(name, opts = {}) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/services/forest_liana/collection.rb', line 13

def self.action(name, opts = {})
  collection = ForestLiana.apimap.find do |x|
    x.name == self.collection_name.try(:to_s)
  end

  return if collection.blank?

  collection.actions << ForestLiana::Model::Action.new({
    name: name,
    http_method: opts[:http_method],
    endpoint: opts[:endpoint],
    fields: opts[:fields]
  })
end

.fields(fields) ⇒ Object



4
5
6
7
8
9
10
11
# File 'app/services/forest_liana/collection.rb', line 4

def self.fields(fields)
  collection = ForestLiana::Model::Collection.new({
    name: self.collection_name,
    fields: fields
  })

  ForestLiana.apimap << collection
end