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

The simplest {Designator}. It resolves actors by their unique ID, such as an autoincrementing ID in a relational database.

The ID is available as the {Designator#value}. If the Designator is instantiated with a live instance (see {Designator#initialize}) then it is re-used and a query to the database is avoided.

The designator string representation for user 42 is +“user:42”+.

Public Instance Methods

describe(*) click to toggle source

This {Designator} description

@return [String] the {User}'s name.

# File lib/eaco/cucumber/active_record/user/designators/user.rb, line 23
def describe(*)
  "User '%s'" % [target_user.name]
end
resolve() click to toggle source

{User}s matching this designator.

@return [Array] this very {User} wrapped in an Array.

# File lib/eaco/cucumber/active_record/user/designators/user.rb, line 32
def resolve
  [target_user]
end

Private Instance Methods

target_user() click to toggle source

Looks up this user by ID, and memoizes it using the {Designator#instance=} accessor.

@return [User] this very user.

# File lib/eaco/cucumber/active_record/user/designators/user.rb, line 43
def target_user
  self.instance ||= ActiveRecord::User.find(self.value)
end