Sha256: de733eccd45ae35bc50f4ce55d602d3b86cdcd3cab0c4ed26128a6d73ab31e35

Contents?: true

Size: 1.04 KB

Versions: 2

Compression:

Stored size: 1.04 KB

Contents

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

    def self.definitions
      @definitions
    end

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

    def name
      @name
    end

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

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

    def include(role_expectations)
      @expectations.concat(role_expectations.to_a)
    end

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

    def expectations
      @expectations
    end

    class Expectations
      def self.expected(expectation, description = nil)
        @role ||= Role.new(self.class.name)
        @role.expected(expectation, description)
      end

      def self.to_a
        @role.expectations
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
job_spec-0.2.4 lib/job_spec/role.rb
job_spec-0.2.3 lib/job_spec/role.rb