Sha256: d8e3778a097ea2a472419ae9b33428f2b64c85b0cf1921d6306edee8e85efcb6

Contents?: true

Size: 823 Bytes

Versions: 1

Compression:

Stored size: 823 Bytes

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 salary(range = nil)
      @salary = @salary || range
    end

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

    def expected(expectation)
      @expectations << expectation
    end

    def to_a
      @expectations
    end

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

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
job_spec-0.1.0 lib/job_spec.rb