Sha256: 078fb5e174e426f922938ce9c5c75a9e054087c1fd5b24170100ef6259e7ba19

Contents?: true

Size: 1.43 KB

Versions: 1

Compression:

Stored size: 1.43 KB

Contents

require 'net/http'
require 'uri'

require 'restfulie/client'

require 'restfulie/server/base'
require 'restfulie/server/controller'
require 'restfulie/server/instance'
require 'restfulie/server/marshalling'
require 'restfulie/server/transition'

module Restfulie

  # Sets this class as a restfulie class.
  # You may pass a block defining your own transitions.
  #
  # The transitions added will be concatenated with any extra transitions provided by your resource through
  # the use of state and transition definitions.
  # For every transition its name is the only mandatory field:
  # options = {}
  # [:show, options] # will generate a link to your controller's show action
  #
  # The options can be used to override restfulie's conventions:
  # options[:rel] = "refresh" # will create a rel named refresh
  # options[:action] = "destroy" # will link to the destroy method
  # options[:controller] = another controller # will use another controller's action
  #
  # Any extra options will be passed to the target controller url_for method in order to retrieve
  # the transition's uri.
  def acts_as_restfulie
    extend Restfulie::Server::Base
    include Restfulie::Server::Instance
    include Restfulie::Server::Marshalling
    
    self.send :define_method, :following_transitions do
      transitions = []
      yield( self, transitions ) if block_given?
      transitions
    end
  end
  
end

Object.extend Restfulie

require 'restfulie/unmarshalling'

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
restfulie-0.4.0 lib/restfulie.rb