Sha256: fc4e1e5eb2a75db0626212ceb647a49b5453c4e7bef5a35e5965184ff4308ac0
Contents?: true
Size: 1.97 KB
Versions: 32
Compression:
Stored size: 1.97 KB
Contents
require 'fiona7/builder/obj_class_builder' require 'fiona7/builder/obj_class_updater' require 'fiona7/obj_class_name_mangler' module Fiona7 class TypeSynchronizer attr_reader :type_definition def initialize(type_definition) self.type_definition = type_definition self.real_obj_class = Fiona7::ObjClassNameMangler.new(type_definition.name).mangle end def synchronize return if skip_this_class? Reactor::Sudo.su(Fiona7.root) do if RailsConnector::ObjClass.exists?(:obj_class_name => self.real_obj_class) Fiona7::Builder::ObjClassUpdater.new(self.builder_values).build else Fiona7::Builder::ObjClassBuilder.new(self.builder_values).build end RailsConnector::Meta::EagerLoader.instance.forget_obj_class(self.real_obj_class) end end protected attr_writer :type_definition attr_accessor :real_obj_class def skip_this_class? case self.type_definition.name when 'Scrivito::BasicWidget', 'Scrivito::BasicObj', 'Obj', 'Scrivito::Obj' true else false end end def builder_values { name: self.real_obj_class, attributes: self.builder_attributes } end def builder_attributes self.type_definition.attrs.map do |attribute_definition| next if ['title', 'blob', 'body', 'valid_from', 'valid_until', 'channels', 'suppress_export'].include?(attribute_definition.real_name) desc = { real_name: attribute_definition.real_name, real_type: attribute_definition.real_type, name: attribute_definition.name, type: attribute_definition.type } # this workaround is needed, because attribute_definition.values # always returns a valid value, be it an empty array case attribute_definition.type when :enum, :multienum desc[:values] = attribute_definition.values end desc end.compact end end end
Version data entries
32 entries across 32 versions & 1 rubygems