Sha256: 5f56a3fdc48f4602957d539fec4ab04eee0240f376f47214ca7bd24cdc88e439

Contents?: true

Size: 1.3 KB

Versions: 3

Compression:

Stored size: 1.3 KB

Contents

require "make_restful/version"

module MakeRestful
  extend ActiveSupport::Concern
  extend ActiveSupport::Autoload

  autoload :ClassMethods
  autoload :Loaders
  autoload :RestMethods
  autoload :Rendering
  autoload :PermissibleSet
  autoload :PermissibleActions

  include RestMethods
  include Rendering

  delegate :allow_method?, :allow_format?, :resource_name, :instance_name, to: :klass

  included do

    class_attribute :json_root_node, :collection_loader, :instance_loader, instance_writer: false

    self.instance_loader = {}
    self.collection_loader = {}

    extend ClassMethods

    class_attribute :allowed_actions, :allowed_formats, :pagination_options, :resource_class, instance_writer: false
    attr_reader :resource, :instance, :collection

    self.pagination_options = {}
    self.allowed_actions = PermissibleActions.new(self)
    self.allowed_formats = PermissibleSet.new([:json, :jsonp, :xml])

    private :klass, :allowed_actions, :allowed_formats, :pagination_options, :resource_class, :allow_method?, :allow_format?, :allowed_actions?, :allowed_formats?, :pagination_options?, :resource_class?
    helper_method :resource, :instance, :collection

    resource name.underscore.gsub(/(.*)_controller/,'\1').singularize rescue nil

    include Loaders

  end

  def klass
    self.class
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
make_restful-0.1.13 lib/make_restful.rb
make_restful-0.1.11 lib/make_restful.rb
make_restful-0.1.10 lib/make_restful.rb