Class: Chef::Resource::Database

Inherits:
Chef::Resource show all
Defined in:
lib/cookbooks/database/libraries/resource_database.rb

Instance Method Summary collapse

Constructor Details

#initialize(name, run_context = nil) ⇒ Database

Returns a new instance of Database.



25
26
27
28
29
30
31
# File 'lib/cookbooks/database/libraries/resource_database.rb', line 25

def initialize(name, run_context=nil)
  super
  @resource_name = :database
  @database_name = name
  @allowed_actions.push(:create, :drop, :query)
  @action = :create
end

Instance Method Details

#collation(arg = nil) ⇒ Object



75
76
77
78
79
80
81
# File 'lib/cookbooks/database/libraries/resource_database.rb', line 75

def collation(arg=nil)
  set_or_return(
    :collation,
    arg,
    :kind_of => String
  )
end

#connection(arg = nil) ⇒ Object



41
42
43
44
45
46
47
# File 'lib/cookbooks/database/libraries/resource_database.rb', line 41

def connection(arg=nil)
  set_or_return(
    :connection,
    arg,
    :required => true
  )
end

#connection_limit(arg = nil) ⇒ Object



101
102
103
104
105
106
107
108
# File 'lib/cookbooks/database/libraries/resource_database.rb', line 101

def connection_limit(arg=nil)
  set_or_return(
    :connection_limit,
    arg,
    :kind_of => String,
    :default => '-1'
  )
end

#database_name(arg = nil) ⇒ Object



33
34
35
36
37
38
39
# File 'lib/cookbooks/database/libraries/resource_database.rb', line 33

def database_name(arg=nil)
  set_or_return(
    :database_name,
    arg,
    :kind_of => String
  )
end

#encoding(arg = nil) ⇒ Object



83
84
85
86
87
88
89
90
# File 'lib/cookbooks/database/libraries/resource_database.rb', line 83

def encoding(arg=nil)
  set_or_return(
    :encoding,
    arg,
    :kind_of => String,
    :default => 'DEFAULT'
  )
end

#owner(arg = nil) ⇒ Object



110
111
112
113
114
115
116
# File 'lib/cookbooks/database/libraries/resource_database.rb', line 110

def owner(arg=nil)
  set_or_return(
    :owner,
    arg,
    :kind_of => String
  )
end

#sql(arg = nil, &block) ⇒ Object



49
50
51
52
53
54
55
56
# File 'lib/cookbooks/database/libraries/resource_database.rb', line 49

def sql(arg=nil, &block)
  arg ||= block
  set_or_return(
    :sql,
    arg,
    :kind_of => [String, Proc]
  )
end

#sql_queryObject



58
59
60
61
62
63
64
# File 'lib/cookbooks/database/libraries/resource_database.rb', line 58

def sql_query
  if sql.kind_of?(Proc)
    sql.call
  else
    sql
  end
end

#tablespace(arg = nil) ⇒ Object



92
93
94
95
96
97
98
99
# File 'lib/cookbooks/database/libraries/resource_database.rb', line 92

def tablespace(arg=nil)
  set_or_return(
    :tablespace,
    arg,
    :kind_of => String,
    :default => 'DEFAULT'
  )
end

#template(arg = nil) ⇒ Object



66
67
68
69
70
71
72
73
# File 'lib/cookbooks/database/libraries/resource_database.rb', line 66

def template(arg=nil)
  set_or_return(
    :template,
    arg,
    :kind_of => String,
    :default => 'DEFAULT'
  )
end