Sha256: 111ef33e64d7e1d51ae9d39a6a8815e5f8565b7668f2c81c390bfec511f6e439

Contents?: true

Size: 1.18 KB

Versions: 23

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

23 entries across 23 versions & 1 rubygems

Version Path
eco-helpers-3.0.4 lib/eco/api/usecases/graphql/helpers/location/command/diffs/stages/commandable.rb
eco-helpers-3.0.3 lib/eco/api/usecases/graphql/helpers/location/command/diffs/stages/commandable.rb
eco-helpers-3.0.2 lib/eco/api/usecases/graphql/helpers/location/command/diffs/stages/commandable.rb
eco-helpers-3.0.1 lib/eco/api/usecases/graphql/helpers/location/command/diffs/stages/commandable.rb
eco-helpers-3.0.0 lib/eco/api/usecases/graphql/helpers/location/command/diffs/stages/commandable.rb
eco-helpers-2.7.25 lib/eco/api/usecases/graphql/helpers/location/command/diffs/stages/commandable.rb
eco-helpers-2.7.24 lib/eco/api/usecases/graphql/helpers/location/command/diffs/stages/commandable.rb
eco-helpers-2.7.23 lib/eco/api/usecases/graphql/helpers/location/command/diffs/stages/commandable.rb
eco-helpers-2.7.22 lib/eco/api/usecases/graphql/helpers/location/command/diffs/stages/commandable.rb
eco-helpers-2.7.21 lib/eco/api/usecases/graphql/helpers/location/command/diffs/stages/commandable.rb
eco-helpers-2.7.20 lib/eco/api/usecases/graphql/helpers/location/command/diffs/stages/commandable.rb
eco-helpers-2.7.19 lib/eco/api/usecases/graphql/helpers/location/command/diffs/stages/commandable.rb
eco-helpers-2.7.18 lib/eco/api/usecases/graphql/helpers/location/command/diffs/stages/commandable.rb
eco-helpers-2.7.17 lib/eco/api/usecases/graphql/helpers/location/command/diffs/stages/commandable.rb
eco-helpers-2.7.16 lib/eco/api/usecases/graphql/helpers/location/command/diffs/stages/commandable.rb
eco-helpers-2.7.15 lib/eco/api/usecases/graphql/helpers/location/command/diffs/stages/commandable.rb
eco-helpers-2.7.14 lib/eco/api/usecases/graphql/helpers/location/command/diffs/stages/commandable.rb
eco-helpers-2.7.13 lib/eco/api/usecases/graphql/helpers/location/command/diffs/stages/commandable.rb
eco-helpers-2.7.12 lib/eco/api/usecases/graphql/helpers/location/command/diffs/stages/commandable.rb
eco-helpers-2.7.4 lib/eco/api/usecases/graphql/helpers/location/command/diffs/stages/commandable.rb