Sha256: 6debc2eb719002247f3502588c78c82186b720ab92d2701560c5d49798fe1949

Contents?: true

Size: 1.16 KB

Versions: 3

Compression:

Stored size: 1.16 KB

Contents

# frozen_string_literal: true

module KepplerFrontend
  module Views
    # CodeHandler
    class Update
      def initialize(view_data)
        @view = view_data
      end

      def change_name(name)
        case @view.format_result
        when 'HTML'
          update_html(name)
        when 'JS'
          update_remote_js(name)
        when 'Action'
          update_only_action(name)
        end
      rescue StandardError
        false
      end

      def update_html(name)
        service('actions').update(name)
        service('html').update(name)
        service('css').update(name)
        service('js').update(name)
        true
      rescue StandardError
        false
      end

      def update_remote_js(name)
        service('actions').update(name)
        service('remote_js').update(name)
        true
      rescue StandardError
        false
      end

      def update_only_action(name)
        service('actions').update(name)
        true
      rescue StandardError
        false
      end

      private

      def service(name)
        model = "KepplerFrontend::Views::#{name.camelize}Handler"
        model.constantize.new(@view)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
keppler-2.1.18 installer/core/rockets/keppler_frontend/app/services/keppler_frontend/views/update.rb
keppler-2.1.17 installer/core/rockets/keppler_frontend/app/services/keppler_frontend/views/update.rb
keppler-2.1.16 installer/core/rockets/keppler_frontend/app/services/keppler_frontend/views/update.rb