Sha256: bdb63a9626d4b80b486d473dd9ca523d434bae4fba20e93b6f1b48726ba3f29b
Contents?: true
Size: 1.22 KB
Versions: 4
Compression:
Stored size: 1.22 KB
Contents
Api = Dao.api do description 'ping!' interface('/ping'){ data.update :time => Time.now } ## this is simply a suggested way to model your api. it is not required. # attr_accessor :effective_user attr_accessor :real_user def initialize(*args) options = args.extract_options!.to_options! effective_user = args.shift || options[:effective_user] || options[:user] real_user = args.shift || options[:real_user] || effective_user @effective_user = user_for(effective_user) if effective_user @real_user = user_for(real_user) if real_user @real_user ||= @effective_user end def user_for(arg) User.respond_to?(:for) ? User.for(arg) : User.find(arg) end alias_method('user', 'effective_user') alias_method('user=', 'effective_user=') alias_method('current_user', 'effective_user') alias_method('current_user=', 'effective_user=') def api self end def logged_in? @effective_user and @real_user end def user? logged_in? end def current_user effective_user end def current_user? !!effective_user end end unloadable(Api) def api(*args, &block) Api.new(*args, &block) end
Version data entries
4 entries across 4 versions & 1 rubygems