conversionfoundry / breeze

A Ruby on Rails CMS for brochure-style websites.
Other
3 stars 2 forks source link

Remove method_missing in Breeze::Admin::User #43

Open isaacfreeman opened 11 years ago

isaacfreeman commented 11 years ago

Breeze::Admin::User has a method_missing method whose only purpose is to provide convenience methods for CanCan roles

e.g. user.admin? instead of user.roles.include? :admin

I think the latter code is easier to interpret (it tells you that admin is a role), so I'd like to remove the method_missing.

  def method_missing(sym, *args)
    if sym.to_s =~ /^(\w+)\?$/ && CORE_ROLES.include?($1.to_sym)
      roles.include? $1.to_sym
    else
      super
    end
  end