Class: XMigra::ImpdeclMigrationAdder::SupportedObjectDeserializer

Inherits:
Object
  • Object
show all
Defined in:
lib/xmigra/impdecl_migration_adder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(object_name, db_specifics) ⇒ SupportedObjectDeserializer

Returns a new instance of SupportedObjectDeserializer.



224
225
226
227
# File 'lib/xmigra/impdecl_migration_adder.rb', line 224

def initialize(object_name, db_specifics)
  @object_name = object_name
  @db_specifics = db_specifics
end

Instance Attribute Details

#db_specificsObject (readonly)

Returns the value of attribute db_specifics.



229
230
231
# File 'lib/xmigra/impdecl_migration_adder.rb', line 229

def db_specifics
  @db_specifics
end

#object_nameObject (readonly)

Returns the value of attribute object_name.



229
230
231
# File 'lib/xmigra/impdecl_migration_adder.rb', line 229

def object_name
  @object_name
end

Instance Method Details

#deserialize(yaml_node) ⇒ Object



231
232
233
234
235
236
237
238
239
240
241
242
243
# File 'lib/xmigra/impdecl_migration_adder.rb', line 231

def deserialize(yaml_node)
  data = yaml_node.to_ruby
  if klass = ImpdeclMigrationAdder.support_type(yaml_node.tag)
    klass.new(@object_name, data).extend(@db_specifics)
  else
    if data.respond_to? :name=
      data.name = @object_name
    elsif data.kind_of? Hash
      data['name'] = @object_name
    end
    data
  end
end