Sha256: c0d4fb8396ac72b617b6542e9bdd9bc76d1b5a0fac490c3d4ad6f2f0668d9369

Contents?: true

Size: 1.49 KB

Versions: 6

Compression:

Stored size: 1.49 KB

Contents

module Anoubis
  module Output
    ##
    # Output subclass that represents data for edit(new) action
    class Edit < Basic
      # @!attribute [rw]
      # @return [String] the title of edit data
      class_attribute :title

      # @!attribute [rw] fields
      #   @return [Array] array of output fields
      class_attribute :fields

      # @!attribute [rw]
      # @return [Hash] the hash of defined fields.
      class_attribute :values, default: {}

      # @!attribute [rw]
      # @return [Hash] the hash of additional field options.
      class_attribute :options, default: {}

      # @!attribute [rw]
      # @return [String] additional action after update
      class_attribute :action


      ##
      # Initializes menu output data. Generates default values.
      def initialize
        super
        self.title = ''
        self.fields = nil
        self.values = {}
        self.options = {}
        self.action = ''
      end

      ##
      # Generates hash representation of output class
      # @return [Hash] hash representation of all data
      def to_h
        result = super.to_h
        return result if self.result != 0
        result[:title] = self.title if self.title != ''
        result[:fields] = self.fields if self.fields
        result[:action] = self.action if self.action != ''
        result.merge!({
                          values: self.values,
                          options: self.options_to_json(self.options)
                      })
        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/edit.rb
anoubis-1.0.11 app/controllers/anoubis/output/edit.rb
anoubis-1.0.10 app/controllers/anoubis/output/edit.rb
anoubis-1.0.8 app/controllers/anoubis/output/edit.rb
anoubis-1.0.7 app/controllers/anoubis/output/edit.rb
anoubis-1.0.1 app/controllers/anoubis/output/edit.rb