Sha256: 348ccd27efb2147054bf7d9a48ef7bedc9d0a8cce810179be4c9d062233e0f17

Contents?: true

Size: 705 Bytes

Versions: 1

Compression:

Stored size: 705 Bytes

Contents

# frozen_string_literal: true

require 'active_support'

module Azeroth
  # @api public
  # @author Darthjee
  #
  # Concern for building controller methods for the routes
  module Resourceable
    extend ActiveSupport::Concern

    included do
      rescue_from ActiveRecord::RecordNotFound, with: :not_found
    end

    autoload :Builder, 'azeroth/resourceable/builder'
    autoload :ClassMethods, 'azeroth/resourceable/class_methods'

    private

    def render_basic
      action = params[:action]
      respond_to do |format|
        format.json { render json: send("#{action}_resource") }
        format.html { action }
      end
    end

    def not_found
      head :not_found
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
azeroth-0.0.6 lib/azeroth/resourceable.rb