Sha256: 020b240d48af59867eb77fb9d397d5b6ab6383929a28738b25e3693eb1466420

Contents?: true

Size: 932 Bytes

Versions: 5

Compression:

Stored size: 932 Bytes

Contents

module Spontaneous
  module Cli
    class Fields < ::Thor
      include Spontaneous::Cli::TaskUtils
      include ::Simultaneous::Task

      namespace :fields

      desc "update", "Performs asynchronous updates on provided fields"
      method_option :fields, :type => :array, :desc => "List of field IDs to update"
      def update(*args)
        update_fields
      end

      private

      def update_fields
        prepare! :update, :console
        site = Spontaneous::Site.instance
        fields = Spontaneous::Field.find(site.model, *options.fields)
        updater = Spontaneous::Field::Update::Immediate.new(site, fields)
        updater.run
        send_completion_event(updater)
      end

      def send_completion_event(updater)
        unlocked_pages = updater.pages.reject { |p| p.locked_for_update? }
        simultaneous_event('page_lock_status', unlocked_pages.map(&:id).to_json)
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
spontaneous-0.2.0.beta10 lib/spontaneous/cli/fields.rb
spontaneous-0.2.0.beta9 lib/spontaneous/cli/fields.rb
spontaneous-0.2.0.beta8 lib/spontaneous/cli/fields.rb
spontaneous-0.2.0.beta7 lib/spontaneous/cli/fields.rb
spontaneous-0.2.0.beta6 lib/spontaneous/cli/fields.rb