Class: JobSpec::Role

Inherits:
Object
  • Object
show all
Defined in:
lib/job_spec/role.rb

Defined Under Namespace

Classes: Expectations

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, &block) ⇒ Role

Returns a new instance of Role.



12
13
14
15
16
# File 'lib/job_spec/role.rb', line 12

def initialize(name, &block)
  @name = name
  @expectations = []
  instance_eval(&block) if block_given?
end

Class Method Details

.definition(name, &block) ⇒ Object



3
4
5
6
# File 'lib/job_spec/role.rb', line 3

def self.definition(name, &block)
  @definitions ||= []
  @definitions << new(name, &block)
end

.definitionsObject



8
9
10
# File 'lib/job_spec/role.rb', line 8

def self.definitions
  @definitions
end

Instance Method Details

#description(description = nil) ⇒ Object



22
23
24
# File 'lib/job_spec/role.rb', line 22

def description(description = nil)
  @description = @description || description
end

#expectationsObject



38
39
40
# File 'lib/job_spec/role.rb', line 38

def expectations
  @expectations
end

#expected(expectation, description = nil) ⇒ Object



34
35
36
# File 'lib/job_spec/role.rb', line 34

def expected(expectation, description = nil)
  @expectations << { expectation: expectation, description: description, group: nil }
end

#include(role_expectations, as:) ⇒ Object



30
31
32
# File 'lib/job_spec/role.rb', line 30

def include(role_expectations, as:)
  @expectations.concat(role_expectations.to_a.map { |expectation| expectation.merge(group: as) })
end

#nameObject



18
19
20
# File 'lib/job_spec/role.rb', line 18

def name
  @name
end

#salary(range = nil) ⇒ Object



26
27
28
# File 'lib/job_spec/role.rb', line 26

def salary(range = nil)
  @salary = @salary || range
end