Sha256: 6f1c03d04d38c3da7b6bb86229a8fb5e4c3ec44a61a1c4d2b6de51b72281af0a

Contents?: true

Size: 1.04 KB

Versions: 18

Compression:

Stored size: 1.04 KB

Contents

shared_context 'command graph' do
  include_context 'container'

  before do
    configuration.relation :users do
      def by_name(name)
        restrict(name: name)
      end
    end

    configuration.relation :tasks do
      def by_user_and_title(user, title)
        by_user(user).by_title(title)
      end

      def by_user(user)
        restrict(user: user)
      end

      def by_title(title)
        restrict(title: title)
      end
    end

    configuration.relation :books
    configuration.relation :tags

    configuration.commands(:users) do
      define(:create) do
        result :one
      end
    end

    configuration.commands(:books) do
      define(:create) do
        before :associate

        def associate(tuples, user)
          tuples.map { |t| t.merge(user: user.fetch(:name)) }
        end
      end
    end

    configuration.commands(:tags) do
      define(:create) do
        before :associate

        def associate(tuples, task)
          tuples.map { |t| t.merge(task: task.fetch(:title)) }
        end
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
rom-3.3.3 spec/shared/command_graph.rb
rom-3.3.2 spec/shared/command_graph.rb
rom-3.3.1 spec/shared/command_graph.rb
rom-3.3.0 spec/shared/command_graph.rb
rom-3.2.3 spec/shared/command_graph.rb
rom-3.2.2 spec/shared/command_graph.rb
rom-3.2.1 spec/shared/command_graph.rb
rom-3.2.0 spec/shared/command_graph.rb
rom-3.1.0 spec/shared/command_graph.rb
rom-3.0.3 spec/shared/command_graph.rb
rom-3.0.2 spec/shared/command_graph.rb
rom-3.0.1 spec/shared/command_graph.rb
rom-3.0.0 spec/shared/command_graph.rb
rom-3.0.0.rc2 spec/shared/command_graph.rb
rom-3.0.0.rc1 spec/shared/command_graph.rb
rom-3.0.0.beta3 spec/shared/command_graph.rb
rom-3.0.0.beta2 spec/shared/command_graph.rb
rom-3.0.0.beta1 spec/shared/command_graph.rb