Sha256: ac5975d8b534264ce654f21d8f980634561fdddbf05ff2c6155c2d06f49d34f7

Contents?: true

Size: 1 KB

Versions: 7

Compression:

Stored size: 1 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
        def execute(tuples, user)
          super(tuples.map { |t| t.merge(user: user.fetch(:name)) })
        end
      end
    end

    configuration.commands(:tags) do
      define(:create) do
        def execute(tuples, task)
          super(tuples.map { |t| t.merge(task: task.fetch(:title)) })
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
rom-2.0.2 spec/shared/command_graph.rb
rom-2.0.1 spec/shared/command_graph.rb
rom-2.0.0 spec/shared/command_graph.rb
rom-1.0.0 spec/shared/command_graph.rb
rom-1.0.0.rc1 spec/shared/command_graph.rb
rom-1.0.0.beta2 spec/shared/command_graph.rb
rom-1.0.0.beta1 spec/shared/command_graph.rb