Class: URI::Generic

Inherits:
Object show all
Defined in:
lib/epitools/core_ext/uri.rb

Instance Method Summary collapse

Instance Method Details

#paramsObject

Return a Hash of the variables in the query string



23
24
25
# File 'lib/epitools/core_ext/uri.rb', line 23

def params
  @params ||= (@query ? @query.to_params : {})
end

#params=(new_params) ⇒ Object

Update all the params at once



30
31
32
33
34
# File 'lib/epitools/core_ext/uri.rb', line 30

def params=(new_params)
  # self.query = new_params.to_params
  raise "params must be a Hash" unless new_params.is_a? Hash
  @params = new_params
end

#queryObject

Get the query string



8
9
10
# File 'lib/epitools/core_ext/uri.rb', line 8

def query
  params.to_query
end

#query=(new_query) ⇒ Object

Set the query string



15
16
17
18
# File 'lib/epitools/core_ext/uri.rb', line 15

def query=(new_query)
  @params = new_query&.to_params
  @query  = new_query
end

#to_strObject

URIs are strings, dammit!



48
49
50
# File 'lib/epitools/core_ext/uri.rb', line 48

def to_str
  to_s
end