Class: DiandianOAuth::API::Interface::Params
- Inherits:
-
Object
- Object
- DiandianOAuth::API::Interface::Params
- Defined in:
- lib/diandian_oauth/api/interface.rb
Overview
Param
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
-
#initialize(params = {}) ⇒ Params
constructor
A new instance of Params.
- #to_a ⇒ Object
- #to_h ⇒ Object
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_a ⇒ Object
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_h ⇒ Object
66 67 68 |
# File 'lib/diandian_oauth/api/interface.rb', line 66 def to_h @params end |