Class: Osmer

Inherits:
Object
  • Object
show all
Includes:
Configurable, Utils
Defined in:
lib/osmer.rb,
lib/osmer/version.rb

Defined Under Namespace

Modules: Configurable, Data, Mapper, Schema, Target, Utils, VERSION Classes: App, Dsl, ThorBase, Updater

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Configurable

#configure

Methods included from Utils

#camelize, #underscore

Constructor Details

#initializeOsmer

Returns a new instance of Osmer.



47
48
49
# File 'lib/osmer.rb', line 47

def initialize
  @schemas = []
end

Instance Attribute Details

#prefixObject

Returns the value of attribute prefix.



45
46
47
# File 'lib/osmer.rb', line 45

def prefix
  @prefix
end

#schemasObject (readonly)

Returns the value of attribute schemas.



44
45
46
# File 'lib/osmer.rb', line 44

def schemas
  @schemas
end

Instance Method Details

#add_schema(name, options) ⇒ Object



51
52
53
54
55
56
57
58
59
# File 'lib/osmer.rb', line 51

def add_schema(name, options)
  type = options.delete(:type) || 'custom'

  require "osmer/schema/#{type}"

  schema = Osmer::Schema.const_get(camelize type).new self, name, options
  schemas << schema
  schema
end

#create_all!(db) ⇒ Object



65
66
67
# File 'lib/osmer.rb', line 65

def create_all!(db)
  @schemas.each{|s| s.create! db }
end

#drop_all!(db) ⇒ Object



69
70
71
# File 'lib/osmer.rb', line 69

def drop_all!(db)
  @schemas.reverse.each{|s| s.drop! db }
end

#find_schema(name) ⇒ Object



61
62
63
# File 'lib/osmer.rb', line 61

def find_schema(name)
  schemas.find{|s| s.name.to_s == name.to_s }
end

#recreate_all!(db) ⇒ Object



73
74
75
76
# File 'lib/osmer.rb', line 73

def recreate_all!(db)
  drop_all! db
  create_all! db
end