Module: Subledger::Path

Defined in:
lib/subledger/path.rb

Class Method Summary collapse

Class Method Details

.for_collect(args) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/subledger/path.rb', line 15

def self.for_collect args
  action          = args[:action]
  state           = args[:state]
  limit           = args[:limit]
  collection_name = args[:collection_name]

  key   = key_for args
  value = URI.escape value_for( args ).to_s

  path = for_collection( args ) + '?'

  query_params = []

  query_params << "state=#{    state  }" unless collection_name == :account_lines
  query_params << "action=#{   action }"
  query_params << "#{ key }=#{ value  }" unless value.respond_to?( :length ) and value.length.zero?
  query_params << "limit=#{    limit  }" unless limit.nil?

  path + query_params.join('&')
end

.for_collection(args) ⇒ Object



3
4
5
# File 'lib/subledger/path.rb', line 3

def self.for_collection args
  "/#{ API_VERSION }#{ path args }"
end

.for_entity(args) ⇒ Object



7
8
9
# File 'lib/subledger/path.rb', line 7

def self.for_entity args
  "#{ for_collection args }/#{ args[ :anchor ].id }"
end

.for_entity_without_api_version(args) ⇒ Object



11
12
13
# File 'lib/subledger/path.rb', line 11

def self.for_entity_without_api_version args
  "#{ path args }/#{ args[ :anchor ].id }"
end