Class: Kangaroo::Util::Loader

Inherits:
Object
  • Object
show all
Defined in:
lib/kangaroo/util/loader.rb,
lib/kangaroo/util/loader/model.rb,
lib/kangaroo/util/loader/namespace.rb,
lib/kangaroo/util/loader/root_namespace.rb

Defined Under Namespace

Modules: Model, Namespace, RootNamespace

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(model_names, database, namespace = "Oo") ⇒ Loader

Initialize a Loader instance

Parameters:

  • model_names (Array)

    List of model names / patterns to load



15
16
17
18
19
20
# File 'lib/kangaroo/util/loader.rb', line 15

def initialize model_names, database, namespace = "Oo"
  @namespace = namespace[0,2] == "::" ? namespace : "::#{namespace}"
  @database = database
  @model_names = model_names
  sanitize_model_names
end

Instance Attribute Details

#databaseObject

Returns the value of attribute database.



10
11
12
# File 'lib/kangaroo/util/loader.rb', line 10

def database
  @database
end

#model_namesObject

Returns the value of attribute model_names.



10
11
12
# File 'lib/kangaroo/util/loader.rb', line 10

def model_names
  @model_names
end

#modelsObject

Returns the value of attribute models.



10
11
12
# File 'lib/kangaroo/util/loader.rb', line 10

def models
  @models
end

#namespaceObject

Returns the value of attribute namespace.



10
11
12
# File 'lib/kangaroo/util/loader.rb', line 10

def namespace
  @namespace
end

Instance Method Details

#load!Array

Loads matching models and uses RubyAdapter to create the neccessary Ruby classes.

Returns:

  • (Array)

    list of ruby models



26
27
28
29
30
# File 'lib/kangaroo/util/loader.rb', line 26

def load!
  load_oo_models
  sort_oo_models
  adapt_oo_models
end