Class: OpenpayUtils::SearchParams

Inherits:
OpenStruct
  • Object
show all
Defined in:
lib/openpay/utils/search_params.rb

Instance Method Summary collapse

Instance Method Details

#to_strObject Also known as: to_s



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/openpay/utils/search_params.rb', line 8

def to_str
  filter = '?'
  self.marshal_dump.each do |attribute, value|
    if attribute =~ /(\w+)_(gte|lte)/
      square_bracket_open_encode = CGI.escape('[')
      square_bracket_close_encode = CGI.escape(']')
      attribute = "#{$1}#{square_bracket_open_encode}#{$2}#{square_bracket_close_encode}"
    end
    filter << "#{attribute}=#{value}&"
  end
  filter.sub(/\&$/, '')
end