Class: Factual::Write::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/factual/write/base.rb

Direct Known Subclasses

Boost, Clear, Flag, Insert, Submit

Instance Method Summary collapse

Constructor Details

#initialize(api, params) ⇒ Base

Returns a new instance of Base.



4
5
6
7
8
# File 'lib/factual/write/base.rb', line 4

def initialize(api, params)
  @api = api
  @params = params
  @params_on_path = [:table, :factual_id]
end

Instance Method Details

#bodyObject



14
15
16
17
# File 'lib/factual/write/base.rb', line 14

def body
  keys = @params.keys.reject { |key| @params_on_path.include?(key) }
  keys.map { |key| "#{key}=#{CGI.escape(stringify(@params[key]))}" }.join("&")
end

#pathObject



10
11
12
# File 'lib/factual/write/base.rb', line 10

def path
  raise "Virtual method called"
end

#writeObject



19
20
21
# File 'lib/factual/write/base.rb', line 19

def write
  @api.post(self)
end