Module: MiniApi

Extended by:
ActiveSupport::Concern
Defined in:
lib/mini_api.rb,
lib/mini_api/config.rb,
lib/mini_api/railtie.rb,
lib/mini_api/version.rb,
lib/mini_api/responder.rb,
lib/mini_api/serialization.rb,
lib/mini_api/case_transform.rb,
lib/mini_api/model_responder.rb,
lib/mini_api/default_responder.rb,
lib/mini_api/relation_responder.rb,
lib/mini_api/translation/message.rb,
lib/mini_api/exceptions/kaminari_not_installed.rb,
lib/mini_api/exceptions/case_transform_option_invalid.rb

Overview

Entrypoint module

Defined Under Namespace

Modules: CaseTransform, Serialization, Translation Classes: CaseTransformOptionInvalid, Config, DefaultResponder, KaminariNotInstalled, ModelResponder, Railtie, RelationResponder, Responder

Constant Summary collapse

VERSION =
'0.1.6'

Instance Method Summary collapse

Instance Method Details

#pageObject



28
29
30
# File 'lib/mini_api.rb', line 28

def page
  params[:page].to_i || 1
end

#per_pageObject



32
33
34
35
36
37
38
# File 'lib/mini_api.rb', line 32

def per_page
  if params[:per_page].to_i.in?([10, 25, 50, 100])
    params[:per_page]
  else
    25
  end
end

#render_json(resource, options = {}) ⇒ Object



22
23
24
25
26
# File 'lib/mini_api.rb', line 22

def render_json(resource, options = {})
  responder = Responder.new(self, resource, options)

  responder.respond
end