Venkat Bagam wrote:
> Hi Folks,
> 
> I have an array has_roles = %w[admin employee ...] which is a subset of
>  application_roles = ["admin", "employee", "manager"...]

I personally like this approach. It's all a matter of taste:

class Application
  @@possible_roles = [:admin, :employee, :manager]

  def self.roles *args
    args.each do |role|
      class_eval do
        define_method(role) do
          true
        end
      end
    end

    (@@possible_roles - args).each do |non_role|
      class_eval do
        define_method(non_role) do
          false
        end
      end
    end
  end
end

class MyApplication < Application
  roles :admin, :employee
end

my_app = MyApplication.new
puts my_app.admin        # => true
puts my_app.manager    # => false

-- 
Posted via http://www.ruby-forum.com/.