Sha256: ad3679106eba2adb0700777078315c1d21e5faa4af6905b9cdb36b66530769f0
Contents?: true
Size: 1.03 KB
Versions: 2
Compression:
Stored size: 1.03 KB
Contents
module Permission class Base require 'forwardable' extend Forwardable # delegate important object methods so they don't return the values for the proxy - am I missing any?? def_delegators :@object, :==, :=~, :class, :enum_for, :eql?, :new, :freeze, :frozen?, :hash, :id, :instance_of?, :is_a?, :kind_of?, :method, :methods, :object_id, :respond_to?, :send, :taint, :tainted?, :to_a, :to_enum, :to_s, :to_yaml, :to_yaml_properties, :to_yaml_style, :type, :untaint attr_accessor :user, :object DEFAULT_FINDERS = /^((find|with).*|first|last|all|children|paginate|scoped|count)$/ DEFAULT_SEARCHES = /^search_.*/ def initialize(params) @user = params[:user] @object = params[:object] end def method_missing(method, *args) object.send(method, *args) end protected def check_roles(user, roles, object) roles.each do |role| return true if user != nil && user.has_role?(user, object) end false end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
johnsbrn-has_permission-0.1.1 | lib/permission/base.rb |
johnsbrn-has_permission-0.1.3 | lib/permission/base.rb |