class Eaco::Cucumber::ActiveRecord::User::Designators::Department

A {Designator} based on a the {Department} an {User} occupies a {Position} in. It resolves {Actor}s by id looking them up through the {Position} model.

As {Department}s have unique names, their name instead of their ID is used in this example.

The Department name is available as the {Designator#value}.

The String representation for an example ICT Department is +“department:ICT”+.

Public Instance Methods

describe(*) click to toggle source

This {Designator} description.

@return [String] the {Department} name, such as ICT or COM

or EXE or BAT.
# File lib/eaco/cucumber/active_record/user/designators/department.rb, line 27
def describe(*)
  department.name
end
resolve() click to toggle source

{User}s matching this designator.

@return [Array] all users currently occupying a position in

this Department
# File lib/eaco/cucumber/active_record/user/designators/department.rb, line 37
def resolve
  department.users
end

Private Instance Methods

department() click to toggle source

Looks up this Department by name, and memoizes it in an instance variable.

@return [ActiveRecord::Department] the referenced department

# File lib/eaco/cucumber/active_record/user/designators/department.rb, line 48
def department
  @_department ||= ActiveRecord::Department.
    where(name: self.value).first!
end