Sha256: fc7432c9049df34ef745dff211bc97d730eb186142507f428de41759646b1aae

Contents?: true

Size: 868 Bytes

Versions: 1

Compression:

Stored size: 868 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
        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

      private

      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

1 entries across 1 versions & 1 rubygems

Version Path
spontaneous-0.2.0.beta5 lib/spontaneous/cli/fields.rb