Sha256: f07fbae88257a77fc2469ea0469d75487b32c68b68ef9a0311a055c5c88ad3a5

Contents?: true

Size: 1015 Bytes

Versions: 32

Compression:

Stored size: 1015 Bytes

Contents

require "fiona7/json/obj_decorator"

module Fiona7
  module JSON
    class ReverseObjDecorator < ObjDecorator
      def as_json(*args)
        with_types = super()
        reverse_types = {}

        with_types.each do |attr, (value, type)|
          if type.nil?
            reverse_types[attr] = value
          else
            reverse_types[attr] = [type, value]
          end
        end

        if reverse_types[:_widget_pool] && !reverse_types[:_widget_pool].empty?
          widgets_reverse_types = reverse_types[:_widget_pool].map do |id, values|
            reversed_values = {}
            values.each do |attr, (value, type)|
              if type.nil?
                reversed_values[attr] = value
              else
                reversed_values[attr] = [type, value]
              end
            end
            [id, reversed_values]
          end

          reverse_types[:_widget_pool] = Hash[widgets_reverse_types]
        end

        reverse_types.as_json(*args)
      end
    end
  end
end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
infopark_fiona7-1.6.1.1.5 lib/fiona7/json/reverse_obj_decorator.rb
infopark_fiona7-1.6.1.1.1 lib/fiona7/json/reverse_obj_decorator.rb
infopark_fiona7-1.6.1.1.0 lib/fiona7/json/reverse_obj_decorator.rb
infopark_fiona7-1.2.0.2.3 lib/fiona7/json/reverse_obj_decorator.rb
infopark_fiona7-1.2.0.2.1 lib/fiona7/json/reverse_obj_decorator.rb
infopark_fiona7-1.2.0.2.2 lib/fiona7/json/reverse_obj_decorator.rb
infopark_fiona7-1.5.5.5.1 lib/fiona7/json/reverse_obj_decorator.rb
infopark_fiona7-1.5.5.5.0 lib/fiona7/json/reverse_obj_decorator.rb
infopark_fiona7-1.2.0.1.4 lib/fiona7/json/reverse_obj_decorator.rb
infopark_fiona7-1.5.5.4.1 lib/fiona7/json/reverse_obj_decorator.rb
infopark_fiona7-1.5.5.4.0 lib/fiona7/json/reverse_obj_decorator.rb
infopark_fiona7-1.2.0.1.3 lib/fiona7/json/reverse_obj_decorator.rb
infopark_fiona7-1.5.5.3.1 lib/fiona7/json/reverse_obj_decorator.rb
infopark_fiona7-1.5.4.3.0 lib/fiona7/json/reverse_obj_decorator.rb
infopark_fiona7-1.5.3.2.0 lib/fiona7/json/reverse_obj_decorator.rb
infopark_fiona7-1.5.3.2.0.pre.beta1 lib/fiona7/json/reverse_obj_decorator.rb
infopark_fiona7-1.5.2.1.0.pre.beta1 lib/fiona7/json/reverse_obj_decorator.rb
infopark_fiona7-1.5.2.0.0 lib/fiona7/json/reverse_obj_decorator.rb
infopark_fiona7-1.2.0.1.1 lib/fiona7/json/reverse_obj_decorator.rb
infopark_fiona7-1.2.0.0.1 lib/fiona7/json/reverse_obj_decorator.rb