Sha256: cd2152d86ddeee0f2f4ec7ead3630be639a72bb78272be260e2105d6a4ca7f44

Contents?: true

Size: 1.16 KB

Versions: 6

Compression:

Stored size: 1.16 KB

Contents

module Anoubis
  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

6 entries across 6 versions & 1 rubygems

Version Path
anoubis-1.0.12 app/controllers/anoubis/output/update.rb
anoubis-1.0.11 app/controllers/anoubis/output/update.rb
anoubis-1.0.10 app/controllers/anoubis/output/update.rb
anoubis-1.0.8 app/controllers/anoubis/output/update.rb
anoubis-1.0.7 app/controllers/anoubis/output/update.rb
anoubis-1.0.1 app/controllers/anoubis/output/update.rb