Class: DiandianOAuth::API::Interface::Params

Inherits:
Object
  • Object
show all
Defined in:
lib/diandian_oauth/api/interface.rb

Overview

Param

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) ⇒ Params

Returns a new instance of Params.



43
44
45
# File 'lib/diandian_oauth/api/interface.rb', line 43

def initialize(params = {})
  @params = params.symbolize_keys!
end

Instance Method Details

#[](key) ⇒ Object



46
47
48
# File 'lib/diandian_oauth/api/interface.rb', line 46

def [] key
  @params[key.to_sym]
end

#[]=(key, value) ⇒ Object



50
51
52
# File 'lib/diandian_oauth/api/interface.rb', line 50

def []= key, value
  @params[key.to_sym] = value
end

#to_aObject



54
55
56
57
58
59
60
61
62
63
64
# File 'lib/diandian_oauth/api/interface.rb', line 54

def to_a
  @params.reduce([]) do |all, (key, value)|
    case value
      when Array
        value.each{|v| all << [key, v]}
      else
        all << [key, value]
    end
    all
  end
end

#to_hObject



66
67
68
# File 'lib/diandian_oauth/api/interface.rb', line 66

def to_h
  @params
end