Class: Fiona7::TypeSynchronizer

Inherits:
Object
  • Object
show all
Defined in:
lib/fiona7/type_synchronizer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type_definition) ⇒ TypeSynchronizer

Returns a new instance of TypeSynchronizer.



9
10
11
12
# File 'lib/fiona7/type_synchronizer.rb', line 9

def initialize(type_definition)
  self.type_definition = type_definition
  self.real_obj_class  = Fiona7::ObjClassNameMangler.new(type_definition.name).mangle
end

Instance Attribute Details

#type_definitionObject

Returns the value of attribute type_definition.



7
8
9
# File 'lib/fiona7/type_synchronizer.rb', line 7

def type_definition
  @type_definition
end

Instance Method Details

#synchronizeObject



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/fiona7/type_synchronizer.rb', line 14

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