Module: Monty::Access
- Defined in:
- lib/monty/access.rb
Instance Method Summary collapse
-
#configure ⇒ Object
Method called by Monty::Watch to trigger parsing of class methods.
-
#permission(name) {|Monty::Permission.new(name)| ... } ⇒ Object
Define permision that defines how your application is accessed.
-
#protected_access(*permissions) ⇒ Object
Define which permissions are accessible to everyone protected_access :my_account, :site_administration.
-
#public_access(*permissions) ⇒ Object
Define which permissions are accessible to everyone public_access :site, :user_registration.
Instance Method Details
#configure ⇒ Object
Method called by Monty::Watch to trigger parsing of class methods
69 70 71 |
# File 'lib/monty/access.rb', line 69 def configure true end |
#permission(name) {|Monty::Permission.new(name)| ... } ⇒ Object
Define permision that defines how your application is accessed.
# All methods on the site resource will be open to users who have
# this permission.
:public_pages do
resource :site
end
# Can use multiple resource statements
:public_pages do
resource :site
resource :posts
end
# Only methods show, edit and update on the users resource will
# be open to users who have this permission.
:my_account_pages do
resource :users do
only :show, :edit, :update
end
end
# All methods except destroy on the users resource will be
# open to users who have this permission.
:manage_users do
resource :users do
except :destroy
end
end
36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/monty/access.rb', line 36 def (name, &block) = Monty::Permission.new(name) if block_given? .instance_eval(&block) else .resource(.name) end unless Monty::Configuration.() Monty::Configuration. << end end |
#protected_access(*permissions) ⇒ Object
Define which permissions are accessible to everyone
protected_access :my_account, :site_administration
63 64 65 |
# File 'lib/monty/access.rb', line 63 def protected_access(*) Monty::Configuration.protected_access = regexes() end |
#public_access(*permissions) ⇒ Object
Define which permissions are accessible to everyone
public_access :site, :user_registration
55 56 57 |
# File 'lib/monty/access.rb', line 55 def public_access(*) Monty::Configuration.public_access = regexes() end |