Module: Mountapi::Handler::Behaviour::InstanceMethods

Defined in:
lib/mountapi/handler/behaviour.rb

Overview

extend instance

Instance Method Summary collapse

Instance Method Details

#bad_request(*args) ⇒ Object



51
52
53
# File 'lib/mountapi/handler/behaviour.rb', line 51

def bad_request(*args)
  Mountapi::Response::BadRequest.new(*args)
end

#base_urlObject



35
36
37
# File 'lib/mountapi/handler/behaviour.rb', line 35

def base_url
  options[:base_url]
end

#callObject

Raises:

  • (NotImplementedError)


63
64
65
# File 'lib/mountapi/handler/behaviour.rb', line 63

def call
  raise NotImplementedError
end

#forbidden(*args) ⇒ Object



59
60
61
# File 'lib/mountapi/handler/behaviour.rb', line 59

def forbidden(*args)
  Mountapi::Response::Forbidden.new(*args)
end

#internal_error(*args) ⇒ Object



55
56
57
# File 'lib/mountapi/handler/behaviour.rb', line 55

def internal_error(*args)
  Mountapi::Response::InternalError.new(*args)
end

#not_found(*args) ⇒ Object



47
48
49
# File 'lib/mountapi/handler/behaviour.rb', line 47

def not_found(*args)
  Mountapi::Response::NotFound.new(*args)
end

#ok(*args) ⇒ Object



43
44
45
# File 'lib/mountapi/handler/behaviour.rb', line 43

def ok(*args)
  Mountapi::Response::Ok.new(*args)
end

#responseObject



67
68
69
# File 'lib/mountapi/handler/behaviour.rb', line 67

def response
  @response ||= Rack::Response.new([])
end

#role_allowed?Boolean

Returns:

  • (Boolean)


71
72
73
74
75
76
77
# File 'lib/mountapi/handler/behaviour.rb', line 71

def role_allowed?
  if Mountapi.config. && self.class.roles
    Mountapi.config..call(params, self.class.roles)
  else
    true
  end
end

#url_for(operation_id, options = {}) ⇒ Object



39
40
41
# File 'lib/mountapi/handler/behaviour.rb', line 39

def url_for(operation_id, options = {})
  Mountapi.url_for(operation_id, base_url, options)
end