Sha256: 2c6655dcbc2e44009ef4a0df1e2f67db2dae4be05715c12a271b63b7d61c4c64

Contents?: true

Size: 1.18 KB

Versions: 17

Compression:

Stored size: 1.18 KB

Contents

class Eco::API::UseCases::GraphQL::Helpers::Location::Command::Diffs
  module Stages
    module Commandable
      class << self
        def included(base)
          super
          base.extend(ClassMethods)
          base.send(:include, DiffSortable)
        end
      end

      module ClassMethods
        def stage_command(stage)
          return :update if stage == :id_name

          stage
        end
      end

      # builds up the particular graphql location commands
      def stage_commands(stage)
        stage_command = self.class.stage_command(stage)
        stage_updates(stage).map do |update|
          {}.tap do |comm|
            comm[stage_command] = symbolize_keys(update)
          end
        end
      end

      private

      def stage_updates(stage)
        aiu = self.class.after_id_update?(stage)
        stage_diffs(stage).map do |dfs|
          dfs.as_update(stage, after_id_update: aiu)
        end
      end

      def stage_diffs(stage)
        raise "There is NO support for stage '#{stage}'. Please review" unless respond_to?(stage)

        sort_diffs(stage) do
          send(stage)
        end
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
eco-helpers-3.0.21 lib/eco/api/usecases/graphql/helpers/location/command/diffs/stages/commandable.rb
eco-helpers-3.0.20 lib/eco/api/usecases/graphql/helpers/location/command/diffs/stages/commandable.rb
eco-helpers-3.0.19 lib/eco/api/usecases/graphql/helpers/location/command/diffs/stages/commandable.rb
eco-helpers-3.0.18 lib/eco/api/usecases/graphql/helpers/location/command/diffs/stages/commandable.rb
eco-helpers-3.0.17 lib/eco/api/usecases/graphql/helpers/location/command/diffs/stages/commandable.rb
eco-helpers-3.0.16 lib/eco/api/usecases/graphql/helpers/location/command/diffs/stages/commandable.rb
eco-helpers-3.0.15 lib/eco/api/usecases/graphql/helpers/location/command/diffs/stages/commandable.rb
eco-helpers-3.0.14 lib/eco/api/usecases/graphql/helpers/location/command/diffs/stages/commandable.rb
eco-helpers-3.0.13 lib/eco/api/usecases/graphql/helpers/location/command/diffs/stages/commandable.rb
eco-helpers-3.0.12 lib/eco/api/usecases/graphql/helpers/location/command/diffs/stages/commandable.rb
eco-helpers-3.0.11 lib/eco/api/usecases/graphql/helpers/location/command/diffs/stages/commandable.rb
eco-helpers-3.0.10 lib/eco/api/usecases/graphql/helpers/location/command/diffs/stages/commandable.rb
eco-helpers-3.0.9 lib/eco/api/usecases/graphql/helpers/location/command/diffs/stages/commandable.rb
eco-helpers-3.0.8 lib/eco/api/usecases/graphql/helpers/location/command/diffs/stages/commandable.rb
eco-helpers-3.0.7 lib/eco/api/usecases/graphql/helpers/location/command/diffs/stages/commandable.rb
eco-helpers-3.0.6 lib/eco/api/usecases/graphql/helpers/location/command/diffs/stages/commandable.rb
eco-helpers-3.0.5 lib/eco/api/usecases/graphql/helpers/location/command/diffs/stages/commandable.rb