Module: Area51::ApiMethod

Defined in:
lib/area_51.rb

Instance Method Summary collapse

Instance Method Details

#area_51(&block) ⇒ Object

This is the entry point into the Area51 library. Here are some usage examples:

class ApplicationController < ActionController::Base
  area_51 do
    authorization_trigger("current_user.active?", :unrestricted) do
      restricted_area "^/memers_only"
      unrestricted_area "^/$"
    end

    authorization_trigger(true, :restricted) do
      restricted_area "/top/secret/path"
      unrestricted_area "/anyone_allowed"
    end

    trigger = proc {
      # Some useful trigger condition here
    }
    authorization_trigger(trigger) do
      unrestricted_area %r{^/totally_open}
      unrestricted_area %r{^/anyone_allowed$}
    end
  end
end

See documentation for authorization_trigger for details on how to use this method.



32
33
34
35
36
37
38
39
40
# File 'lib/area_51.rb', line 32

def area_51(&block)
  self.send :extend, ClassMethods
  self.send :include, InstanceMethods

  self.default_access = :restricted
  self.before_filter :area_51_check_access

  yield
end