Class: QuickbloxApi::Encoder

Inherits:
Object
  • Object
show all
Defined in:
lib/quickblox_api/encoder.rb

Overview

source: github.com/revans/quickblox/ TODO: logic should be simplified and moved into helpers

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(sorted_params) ⇒ Encoder

Returns a new instance of Encoder.



9
10
11
# File 'lib/quickblox_api/encoder.rb', line 9

def initialize(sorted_params)
  @sorted_params = sorted_params
end

Class Method Details

.encode!(sorted_params) ⇒ Object



5
6
7
# File 'lib/quickblox_api/encoder.rb', line 5

def self.encode!(sorted_params)
  new(sorted_params).encode!
end

Instance Method Details

#encode!Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/quickblox_api/encoder.rb', line 13

def encode!
  var = encode(@sorted_params)

  var.map do |k,v|
    if v.is_a?(Hash)
      v.map { |k1,v1| "#{k}[#{k1}]=#{v1}" }.sort.join('&')

    else
      "#{k}=#{v}"

    end

  end.sort.join('&')
end