Sha256: 45a4545a1a54ae0fc140904479a1fb6af09d738e9c8c852ec29d2f64733f6096

Contents?: true

Size: 1.26 KB

Versions: 7

Compression:

Stored size: 1.26 KB

Contents

require "trailblazer/skill"
require "uber/delegates"

# Dependency ("skill") management for Operation.
# Op::[]
# Op::[]=
# Writing, even with an existing name, will never mutate a container.
# Op#[]
# Op#[]=
# Op.(params, { "constructor" => competences })
class Trailblazer::Operation
  module Skill
    # The class-level skill container: Operation::[], ::[]=.
    module Accessors
      # :private:
      def skills
        @skills ||= {}
      end

      extend Uber::Delegates
      delegates :skills, :[], :[]=
    end

    # Overrides Operation::call, creates the Skill hash and passes it to :call.
    module Call
      def call(options={}, *dependencies)
        super Trailblazer::Skill.new(options, *dependencies, self.skills)
        # DISCUSS: should this be: Trailblazer::Skill.new(runtime_options: [options, *dependencies], compiletime_options: [self.skills])
      end
      alias :_call :call

      # It really sucks that Ruby doesn't have method overloading where we could simply have
      # two different implementations of ::call.
      # FIXME: that shouldn't be here in this namespace.
      module Positional
        def call(params={}, options={}, *dependencies)
          super(options.merge("params" => params), *dependencies)
        end
      end
    end

  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
trailblazer-operation-0.0.10 lib/trailblazer/operation/skill.rb
trailblazer-operation-0.0.9 lib/trailblazer/operation/skill.rb
trailblazer-operation-0.0.8 lib/trailblazer/operation/skill.rb
trailblazer-operation-0.0.7 lib/trailblazer/operation/skill.rb
trailblazer-operation-0.0.6 lib/trailblazer/operation/skill.rb
trailblazer-operation-0.0.5 lib/trailblazer/operation/skill.rb
trailblazer-operation-0.0.4 lib/trailblazer/operation/skill.rb