##
# This is the class of all Groups. A Group is a role that does not depend
# on context, but rather on membership - a user can be made a member
# of such a role. This might be related to that person's role in the
# organization, for example.
module Arrthorizer
  class Group < Role
    attr_reader :name

    def initialize(name)
      @name = name

      Role.register(self)
    end

    def applies_to_user?(user, context)
      Arrthorizer.membership_service.is_member_of?(user, self)
    end
  end
end


##
# This is the class of all Groups. A Group is a role that does not depend
# on context, but rather on membership - a user can be made a member
# of such a role. This might be related to that person's role in the
# organization, for example.
module Arrthorizer
  class Group < Role
    attr_reader :name

    def initialize(name)
      @name = name

      Role.register(self)
    end

    def applies_to_user?(user, _)
      is_member?(user)
    end

  private
    def is_member?(user)
      Arrthorizer.membership_service.is_member_of?(user, self)
    end
  end
end


Add level of indirection to ease overriding in Groups
Add level of indirection to ease overriding in Groups

The applies_to_user? function is used internally by Arrthorizer, but
if developers want to override the default behavior, this
applies_to_user function makes no semantic sense (for example, it takes
a superfluous parameter). The is_member? function makes semantic sense
and looks better.
