class Readymade::Response

Constants

DEFAULT_STATUSES

Attributes

args[R]
data[R]
status[R]

Public Class Methods

new(status, *args) click to toggle source
# File lib/readymade/response.rb, line 17
def initialize(status, *args)
  @status = status.to_s

  raise NonKeywordArgumentsError if args.present? && !args[0].is_a?(Hash)

  @args = @data = args[0]

  define_singleton_method("#{status}?") do
    true
  end
end

Public Instance Methods

errors() click to toggle source
# File lib/readymade/response.rb, line 29
def errors
  args[:errors].presence || {}
end
method_missing(method_name, *args, &block) click to toggle source
Calls superclass method
# File lib/readymade/response.rb, line 33
def method_missing(method_name, *args, &block)
  return false if method_name.to_s.end_with?('?')

  super
end
respond_to_missing?(method_name, include_private = false) click to toggle source
Calls superclass method
# File lib/readymade/response.rb, line 39
def respond_to_missing?(method_name, include_private = false)
  method_name.to_s.end_with?('?') || super
end