Sha256: b115e87924c8353993cc334791874c31a33e730f8f71f940e55192ad042cb9ef

Contents?: true

Size: 1.26 KB

Versions: 22

Compression:

Stored size: 1.26 KB

Contents

require 'rest_in_peace/definition_proxy/resource_method_definitions'
require 'rest_in_peace/definition_proxy/collection_method_definitions'
require 'rest_in_peace/definition_proxy/attributes_definitions'
require 'rest_in_peace/active_model_api'

module RESTinPeace
  class DefinitionProxy
    class InvalidArgument < RESTinPeace::DefaultError
      def initialize
        super('Given parameter must respond to `merge`.')
      end
    end

    def initialize(target)
      @target = target
    end

    def resource(&block)
      method_definitions = RESTinPeace::DefinitionProxy::ResourceMethodDefinitions.new(@target)
      method_definitions.instance_eval(&block)
    end

    def collection(&block)
      method_definitions = RESTinPeace::DefinitionProxy::CollectionMethodDefinitions.new(@target)
      method_definitions.instance_eval(&block)
    end

    def attributes(&block)
      method_definitions = RESTinPeace::DefinitionProxy::AttributesDefinitions.new(@target)
      method_definitions.instance_eval(&block)
    end

    def acts_as_active_model
      @target.send(:include, RESTinPeace::ActiveModelAPI)
    end

    def namespace_attributes_with(namespace)
      @target.rip_namespace = namespace
    end

    def use_api(api)
      @target.api = api
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
rest-in-peace-6.2.0 lib/rest_in_peace/definition_proxy.rb
rest-in-peace-6.1.1 lib/rest_in_peace/definition_proxy.rb
rest-in-peace-6.1.0 lib/rest_in_peace/definition_proxy.rb
rest-in-peace-6.0.4 lib/rest_in_peace/definition_proxy.rb
rest-in-peace-6.0.3 lib/rest_in_peace/definition_proxy.rb
rest-in-peace-6.0.2 lib/rest_in_peace/definition_proxy.rb
rest-in-peace-6.0.0 lib/rest_in_peace/definition_proxy.rb
rest-in-peace-5.1.0 lib/rest_in_peace/definition_proxy.rb
rest-in-peace-5.0.2 lib/rest_in_peace/definition_proxy.rb
rest-in-peace-5.0.1 lib/rest_in_peace/definition_proxy.rb
rest-in-peace-5.0.0 lib/rest_in_peace/definition_proxy.rb
rest-in-peace-4.2.1 lib/rest_in_peace/definition_proxy.rb
rest-in-peace-4.2.0 lib/rest_in_peace/definition_proxy.rb
rest-in-peace-4.1.1 lib/rest_in_peace/definition_proxy.rb
rest-in-peace-4.1.0 lib/rest_in_peace/definition_proxy.rb
rest-in-peace-4.0.0 lib/rest_in_peace/definition_proxy.rb
rest-in-peace-3.0.0 lib/rest_in_peace/definition_proxy.rb
rest-in-peace-2.0.4 lib/rest_in_peace/definition_proxy.rb
rest-in-peace-2.0.3 lib/rest_in_peace/definition_proxy.rb
rest-in-peace-2.0.2 lib/rest_in_peace/definition_proxy.rb