Module: Authorization::ClassMethods

Defined in:
lib/base_auth.rb

Instance Method Summary collapse

Instance Method Details

#allow(*attrs) ⇒ Object



124
125
126
# File 'lib/base_auth.rb', line 124

def allow( *attrs )
  authorization_filter :allow, attrs
end

#authorization_filter(action, attrs) ⇒ Object



102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# File 'lib/base_auth.rb', line 102

def authorization_filter( action, attrs )
  config = { }
  config.update( attrs.pop ) if attrs.last.is_a?( Hash )
  
  opts = {}
  opts[:only] = config[:only]
  opts[:only] ||= attrs unless attrs.blank?
  opts[:except] = config[:except]
  
  if config[:if]
    
  end
  
  before_filter opts do |controller|
    if action == :allow
      controller.allow! config
    else
      controller.deny! config
    end
  end
end

#deny(*attrs) ⇒ Object



128
129
130
# File 'lib/base_auth.rb', line 128

def deny( *attrs )
  authorization_filter :deny, attrs
end