Top Level Namespace

Defined Under Namespace

Modules: ActiveRecord, Dao, DaoHelper, Kernel, MongoMapper Classes: APIController, Array, DaoGenerator

Constant Summary collapse

Api =
Dao.api do
##
#
  README "    this a dao api\n    \n      so nice\n\n    so good\n  __\n\n##\n#\n  desc '/ping - hello world without a user'\n  call('/ping'){\n    data.update :time => Time.now\n  }\n\n  desc '/pong - hello world with a user'\n  call('/pong'){\n    require_current_user!\n    data.update :time => Time.now\n    data.update :current_user => current_user\n  }\n\n## this is simply a suggested way to model your api.  it is not required.\n#\n  attr_accessor :effective_user\n  attr_accessor :real_user\n\n  def initialize(*args)\n    options = args.extract_options!.to_options!\n    effective_user = args.shift || options[:effective_user] || options[:user]\n    real_user = args.shift || options[:real_user] || effective_user\n    @effective_user = user_for(effective_user) if effective_user\n    @real_user = user_for(real_user) if real_user\n    @real_user ||= @effective_user\n  end\n\n## no doubt you'll want to customize this!\n#\n  def user_for(arg)\n    User.respond_to?(:for) ? User.for(arg) : User.find(arg)\n  end\n\n  alias_method('user', 'effective_user')\n  alias_method('user=', 'effective_user=')\n  alias_method('current_user', 'effective_user')\n  alias_method('current_user=', 'effective_user=')\n  alias_method('effective_user?', 'effective_user')\n  alias_method('real_user?', 'real_user')\n\n  def api\n    self\n  end\n\n  def logged_in?\n    @effective_user and @real_user\n  end\n\n  def user?\n    logged_in?\n  end\n\n  def current_user\n    effective_user\n  end\n\n  def current_user?\n    !!effective_user\n  end\n\n  def require_effective_user!\n    unless effective_user?\n      status :unauthorized\n      return!\n    end\n  end\n\n  def require_real_user!\n    unless real_user?\n      status :unauthorized\n      return!\n    end\n  end\n\n  def require_current_user!\n    require_effective_user! and require_real_user!\n  end\n  alias_method('require_user!', 'require_current_user!')\nend\n"
ApiController =

rails is a bitch - shut her up

APIController

Instance Method Summary collapse

Instance Method Details

#ApiObject

mo betta in development



105
# File 'lib/dao/rails/lib/generators/dao/templates/api.rb', line 105

unloadable(Api)

#dirObject

look for any other apis to load



97
98
99
100
101
# File 'lib/dao/rails/lib/generators/dao/templates/api.rb', line 97

%w( api apis ).each do |dir|
  glob = File.expand_path(File.join(Rails.root, "app/#{ dir }/**/*.rb"))
  files = Dir.glob(glob).sort
  files.each{|file| ::Kernel.load(file)}
end

#tap(value, &block) ⇒ Object



13
14
15
16
# File 'lib/dao/stdext.rb', line 13

def tap(value, &block)
  block.call(value)
  value
end