Sha256: 12d4f65e93354ab9adb1003de0674041d73726b9d2943d85edb0986ea326b1f8

Contents?: true

Size: 1.16 KB

Versions: 1

Compression:

Stored size: 1.16 KB

Contents

module Anubis
  module Output
    ##
    # Output subclass that represents data for update or create action
    class Update < Basic
      # @!attribute [rw]
      # @return [Hash] the hash of defined fields.
      class_attribute :values, default: {}

      # @!attribute [rw]
      # @return [Array<String>] hash of errors
      class_attribute :errors, default: []

      # @!attribute [rw]
      # @return [String] resulting post action
      class_attribute :action, default: ''

      ##
      # Initializes menu output data. Generates default values.
      def initialize
        super
        self.values = {}
        self.errors = []
        self.action = ''
        self.messages[:'-3'] = I18n.t('errors.update_error')
      end

      ##
      # Generates hash representation of output class
      # @return [Hash] hash representation of all data
      def to_h
        result = super.to_h
        result[:errors] = self.errors if self.errors.length > 0
        return result if self.result != 0
        result.merge!({
                          values: self.values,
                          action: self.action
                      })
        result
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
anoubis-1.0.0 app/controllers/anoubis/output/update.rb