Sha256: 204e0f5c31e655b0a2ff34927541dd709470056d56c80c0fa8ca92e66a8902eb

Contents?: true

Size: 1000 Bytes

Versions: 2

Compression:

Stored size: 1000 Bytes

Contents

# frozen_string_literal: true

require 'fetcheable_on_api/configuration'
require 'fetcheable_on_api/filtreable'
require 'fetcheable_on_api/pagineable'
require 'fetcheable_on_api/sortable'
require 'fetcheable_on_api/version'
require 'active_support'

module FetcheableOnApi
  #
  # Configuration
  #
  class << self
    attr_accessor :configuration
  end

  def self.configuration
    @configuration ||= Configuration.new
  end

  def self.configure
    yield(configuration)
  end

  #
  # Supports
  #

  #
  # Public class methods
  #
  def self.included(klass)
    klass.class_eval do
      include Filtreable
      include Sortable
      include Pagineable
    end
  end

  #
  # Public instance methods
  #

  #
  # Protected instance methods
  #
  protected

  def apply_fetcheable(collection)
    collection = apply_sort(collection)
    collection = apply_pagination(collection)
    apply_filters(collection)
  end
end

ActiveSupport.on_load :action_controller do
  include FetcheableOnApi
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fetcheable_on_api-0.1.3 lib/fetcheable_on_api.rb
fetcheable_on_api-0.1.2 lib/fetcheable_on_api.rb