Sha256: 9dcd61103b8b9fb57ccfd3d48a6406369fba82b95958aede160030f3175ec87b
Contents?: true
Size: 1.45 KB
Versions: 1
Compression:
Stored size: 1.45 KB
Contents
module Restfulie module Server module Base # returns the definition for the transaction def existing_transitions(name) transitions[name] end # returns a hash of all possible transitions: Restfulie::Server::Transition def transitions @transitions ||= {} end # returns a hash of all possible states def states @states ||= {} end # adds a new state to the list of possible states def state(name, options = {}) options[:allow] = [options[:allow]] unless options[:allow].kind_of? Array states[name] = options end # defines a new transition. the transition options works in the same way # that following_transition definition does. def transition(name, options = {}, result = nil, &body) transition = Restfulie::Server::Transition.new(name, options, result, body) transitions[name] = transition define_methods_for(self, name, result) controller_name = (self.name + "Controller") end def define_methods_for(type, name, result) return nil if type.respond_to?(name) type.send(:define_method, name) do |*args| self.status = result.to_s unless result == nil end type.send(:define_method, "can_#{name}?") do transitions = self.available_transitions[:allow] transitions.include? name end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
restfulie-0.3 | lib/restfulie/server/base.rb |