Class: JobSpec::Role
- Inherits:
-
Object
- Object
- JobSpec::Role
- Defined in:
- lib/job_spec/role.rb
Defined Under Namespace
Classes: Expectations
Class Method Summary collapse
Instance Method Summary collapse
- #description(description = nil) ⇒ Object
- #expectations ⇒ Object
- #expected(expectation, description = nil) ⇒ Object
- #include(role_expectations, as:) ⇒ Object
-
#initialize(name, &block) ⇒ Role
constructor
A new instance of Role.
- #name ⇒ Object
- #salary(range = nil) ⇒ Object
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 |
.definitions ⇒ Object
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 |
#expectations ⇒ Object
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 |
#name ⇒ Object
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 |