Sha256: 487bc13d9326b259695ffb923a2f696e71ee6400fa59ddfeed74efe620c993e1

Contents?: true

Size: 610 Bytes

Versions: 6

Compression:

Stored size: 610 Bytes

Contents

# frozen_string_literal: true

module ROM::Factory
  module Attributes
    # @api private
    class Callable
      attr_reader :name, :dsl, :block

      # @api private
      def initialize(name, dsl, block)
        @name = name
        @dsl = dsl
        @block = block
      end

      # @api private
      def call(attrs, *args)
        result = attrs[name] || dsl.instance_exec(*args, &block)
        { name => result }
      end

      # @api private
      def value?
        true
      end

      # @api private
      def dependency_names
        block.parameters.map(&:last)
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rom-factory-0.10.2 lib/rom/factory/attributes/callable.rb
rom-factory-0.10.1 lib/rom/factory/attributes/callable.rb
rom-factory-0.10.0 lib/rom/factory/attributes/callable.rb
rom-factory-0.9.1 lib/rom/factory/attributes/callable.rb
rom-factory-0.9.0 lib/rom/factory/attributes/callable.rb
rom-factory-0.8.0 lib/rom/factory/attributes/callable.rb