Method: GitDS::ModelItemClass#create

Defined in:
lib/git-ds/model/item.rb

#create(parent, args = {}) ⇒ Object

Create a new instance of the ModelItemClass owned by the specified parent.

This will create a subdirectory under ModelItemClass.path(parent); the name of the directory is determined by ModelItemClass.ident.

For example, given the following database:

ClassA/a1/ClassB/b1
ClassA/a1/ClassB/b2
ClassA/a2/ClassB/b3

ModelItemClass.create(a2, { :ident => ‘b4’ } ) will create the directory ‘ClassA/a2/ClassB/b4’.

The directory will then be filled by calling ModelItemClass.fill.

Note that this returns the path to the created item, not an instance.



152
153
154
155
156
157
158
# File 'lib/git-ds/model/item.rb', line 152

def create(parent, args={})
  raise "Use Database.root instead of nil for parent" if not parent
  raise "parent is not a ModelItem" if not parent.respond_to? :model

  model = parent.model
  create_in_path(parent.model, parent.path, args)
end