class Orchestrate::Application::Schema
Singleton class to define schema for Orchestrate.io application
Public Class Methods
new()
click to toggle source
# File rails/lib/orchestrate_application/schema.rb, line 9 def initialize @@schema = {} end
Public Instance Methods
collection_names()
click to toggle source
# File rails/lib/orchestrate_application/schema.rb, line 21 def collection_names schema.keys end
collections()
click to toggle source
# File rails/lib/orchestrate_application/schema.rb, line 17 def collections schema end
define_collection(args)
click to toggle source
# File rails/lib/orchestrate_application/schema.rb, line 37 def define_collection(args) load_collection SchemaCollection.new(args) end
define_event_type(collection_name, event_type, properties)
click to toggle source
# File rails/lib/orchestrate_application/schema.rb, line 41 def define_event_type(collection_name, event_type, properties) get(collection_name).define_event_type event_type, properties end
define_graph(collection_name, relation_kind, to_collection)
click to toggle source
# File rails/lib/orchestrate_application/schema.rb, line 45 def define_graph(collection_name, relation_kind, to_collection) get(collection_name).define_graph relation_kind, to_collection end
get(collection_name)
click to toggle source
# File rails/lib/orchestrate_application/schema.rb, line 25 def get(collection_name) schema[collection_name] end
get_collection(name)
click to toggle source
# File rails/lib/orchestrate_application/schema.rb, line 29 def get_collection(name) get(name) end
load(schema)
click to toggle source
Support (optional) loading of schema from a definition file
Example usage:
Orchestrate::Application::Schema.instance.load "./schema.rb"
Example definition file - i.e. “<APP-ROOT>/schema.rb”
Orchestrate::Application::Schema.instance.define_collection( :name => 'films', :properties => [ :Title, :Year, :Rated, :Released, :Runtime, :Genre, :Director, :Writer, :Actors, :Plot, :Poster, :imdbRating, :imdbVotes, :imdbID, :Type, :Response ], :event_types => [ :comments ], :graphs => [ :sequel ], ) Orchestrate::Application::Schema.instance.define_event_type( :collection => 'films', :event_type => :comments, :properties => [ :User, :Comment ] ) Orchestrate::Application::Schema.instance.define_graph( :collection => 'films', :relation_kind => :sequel, :to_collection => 'films', )
# File rails/lib/orchestrate_application/schema.rb, line 79 def load(schema) require schema end
load_collection(collection)
click to toggle source
# File rails/lib/orchestrate_application/schema.rb, line 33 def load_collection(collection) schema[collection.name] = collection end
schema()
click to toggle source
# File rails/lib/orchestrate_application/schema.rb, line 13 def schema @@schema end