Module: ApiProblem

Defined in:
lib/api_problem.rb,
lib/api_problem/railtie.rb,
lib/api_problem/version.rb

Defined Under Namespace

Classes: Railtie

Constant Summary collapse

MissingTitle =
Class.new(StandardError)
MissingProblemType =
Class.new(StandardError)
VERSION =
"0.0.2"

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.build(problem_type, title, options = {}) ⇒ Object



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

def self.build(problem_type, title, options={})
  response ={}
  raise ApiProblem::MissingProblemType if problem_type.nil?
  raise ApiProblem::MissingTitle if title.nil?
  new_options = build_options(options)
  unless new_options.empty?
    { problemType: problem_type, title: title }.merge(new_options)
  else
    { problemType: problem_type, title: title }
  end
end

Instance Method Details

#api_problem(problem_type, title, options = {}) ⇒ Object



20
21
22
# File 'lib/api_problem.rb', line 20

def api_problem(problem_type, title, options={})
  ApiProblem.build problem_type, title, options
end