lolita 3.0.5 → 3.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.rspec +2 -0
- data/GUIDELINE +20 -20
- data/VERSION +1 -1
- data/app/views/components/lolita/field/_boolean.html.erb +1 -0
- data/app/views/components/lolita/field/_select.html.erb +1 -1
- data/app/views/components/lolita/field/_text.html.erb +1 -1
- data/app/views/components/lolita/navigation/_display.html.erb +1 -1
- data/app/views/components/lolita/shared/_flash.html.erb +1 -1
- data/app/views/lolita/layouts/application.html.erb +3 -2
- data/lib/generators/lolita/{copy_assets_generator.rb → assets_generator.rb} +1 -1
- data/lib/generators/lolita/install_generator.rb +6 -3
- data/lib/lolita.rb +136 -135
- data/lib/lolita/adapter/active_record.rb +110 -110
- data/lib/lolita/adapter/mongoid.rb +104 -104
- data/lib/lolita/base_configuration.rb +49 -21
- data/lib/lolita/configuration/base.rb +76 -76
- data/lib/lolita/configuration/factory.rb +46 -0
- data/lib/lolita/configuration/field.rb +31 -45
- data/lib/lolita/configuration/field/boolean.rb +10 -0
- data/lib/lolita/configuration/{field_extensions → field}/collection.rb +25 -17
- data/lib/lolita/configuration/field/datetime.rb +10 -0
- data/lib/lolita/configuration/field/disabled.rb +10 -0
- data/lib/lolita/configuration/field/integer.rb +10 -0
- data/lib/lolita/configuration/field/password.rb +10 -0
- data/lib/lolita/configuration/field/string.rb +11 -0
- data/lib/lolita/configuration/field/text.rb +10 -0
- data/lib/lolita/configuration/tab.rb +5 -25
- data/lib/lolita/configuration/tab/default.rb +24 -0
- data/lib/lolita/configuration/tabs.rb +7 -3
- data/lib/lolita/controllers/component_helpers.rb +16 -1
- data/lib/lolita/errors.rb +2 -0
- data/lib/lolita/mapping.rb +17 -4
- data/lib/lolita/modules/rest.rb +1 -1
- data/lib/lolita/rails/routes.rb +21 -12
- data/lolita.gemspec +15 -5
- data/public/javascripts/lolita/main.js +7 -6
- data/public/javascripts/lolita/tab.js +36 -36
- data/spec/configuration/field_spec.rb +3 -3
- data/spec/configuration/tab_spec.rb +2 -2
- data/spec/configuration/tabs_spec.rb +7 -0
- data/spec/rails_app/public/javascripts/lolita/tab.js +36 -36
- data/spec/rails_app/public/javascripts/rails.js +137 -137
- metadata +16 -6
- data/lib/lolita/version.rb +0 -3
data/.rspec
ADDED
data/GUIDELINE
CHANGED
@@ -1,20 +1,20 @@
|
|
1
|
-
# Creating GEM for Lolita
|
2
|
-
|
3
|
-
When creating GEM, that include new module in one or more of lolita modules, use
|
4
|
-
Lolita.send(:include,YourModule) instead of reopening module.
|
5
|
-
|
6
|
-
# How to install
|
7
|
-
|
8
|
-
gem install lolita
|
9
|
-
|
10
|
-
cd your_project
|
11
|
-
|
12
|
-
rails g lolita:install
|
13
|
-
|
14
|
-
change your project initializers/lolita.rb
|
15
|
-
|
16
|
-
# For cucumber testing
|
17
|
-
gem install akephalos
|
18
|
-
bundle exec cucumber features
|
19
|
-
|
20
|
-
|
1
|
+
# Creating GEM for Lolita
|
2
|
+
|
3
|
+
When creating GEM, that include new module in one or more of lolita modules, use
|
4
|
+
Lolita.send(:include,YourModule) instead of reopening module.
|
5
|
+
|
6
|
+
# How to install
|
7
|
+
|
8
|
+
gem install lolita
|
9
|
+
|
10
|
+
cd your_project
|
11
|
+
|
12
|
+
rails g lolita:install
|
13
|
+
|
14
|
+
change your project initializers/lolita.rb
|
15
|
+
|
16
|
+
# For cucumber testing
|
17
|
+
gem install akephalos
|
18
|
+
bundle exec cucumber features
|
19
|
+
|
20
|
+
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.0.
|
1
|
+
3.0.6
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= check_box resource_name, field.name %>
|
@@ -1 +1 @@
|
|
1
|
-
<%= select resource_name, field.name, field.association_values %>
|
1
|
+
<%= select resource_name, field.name, field.association_values.respond_to?(:call) ? field.association_values.call(self) : field.association_values %>
|
@@ -7,7 +7,7 @@
|
|
7
7
|
theme: "advanced",
|
8
8
|
skin: "cirkuit",
|
9
9
|
mode: "textareas",
|
10
|
-
theme_advanced_buttons1 : "bold,italic,underline,|,justifyleft,justifycenter,justifyright,|,formatselect,|,link,unlink,image",
|
10
|
+
theme_advanced_buttons1 : "bold,italic,underline,|,justifyleft,justifycenter,justifyright,|,formatselect,|,link,unlink,image,code",
|
11
11
|
theme_advanced_buttons2 : "",
|
12
12
|
theme_advanced_buttons3 : "",
|
13
13
|
theme_advanced_toolbar_location: "top",
|
@@ -13,6 +13,7 @@
|
|
13
13
|
<link rel="shortcut icon" href="/favicon.ico">
|
14
14
|
|
15
15
|
<%= stylesheet_link_tag "lolita/default","lolita/style" %>
|
16
|
+
<%= yield :style %>
|
16
17
|
<%= javascript_include_tag "modernizr-1.7.min" %>
|
17
18
|
<%= raw csrf_meta_tag %>
|
18
19
|
</head>
|
@@ -32,9 +33,9 @@
|
|
32
33
|
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.js">
|
33
34
|
</script>
|
34
35
|
<script>
|
35
|
-
window.jQuery || document.write('<script src="jquery-1.5.1.min.js">\x3C/script>')
|
36
|
+
window.jQuery || document.write('<script src="/javascripts/jquery-1.5.1.min.js">\x3C/script>')
|
36
37
|
</script>
|
37
|
-
<%= javascript_include_tag "rails","lolita/tab" %>
|
38
|
+
<%= javascript_include_tag "rails","lolita/tab","lolita/main" %>
|
38
39
|
<%= content_for :script %>
|
39
40
|
</body>
|
40
41
|
</html>
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'generators/helpers/file_helper'
|
2
2
|
module Lolita
|
3
3
|
module Generators
|
4
|
-
class
|
4
|
+
class AssetsGenerator < Rails::Generators::Base
|
5
5
|
include Lolita::Generators::FileHelper
|
6
6
|
desc "Copy all from lolita public directory to project public directory."
|
7
7
|
def copy_all
|
@@ -13,11 +13,14 @@ module Lolita
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def copy_assets
|
16
|
-
generate("lolita:
|
16
|
+
generate("lolita:assets")
|
17
17
|
end
|
18
18
|
|
19
|
-
def
|
20
|
-
|
19
|
+
def install_modules
|
20
|
+
Lolita.modules.each do |module_name|
|
21
|
+
|
22
|
+
invoke "#{module_name.to_s.underscore.gsub("/","_")}:install"
|
23
|
+
end
|
21
24
|
end
|
22
25
|
|
23
26
|
end
|
data/lib/lolita.rb
CHANGED
@@ -1,136 +1,137 @@
|
|
1
|
-
main_time=Time.now
|
2
|
-
|
3
|
-
$:<<File.dirname(__FILE__) unless $:.include?(File.dirname(__FILE__))
|
4
|
-
|
5
|
-
require 'abstract' #FIXME remove from gem
|
6
|
-
require 'active_support/core_ext/numeric/time'
|
7
|
-
require 'active_support/concern'
|
8
|
-
require 'active_support/callbacks'
|
9
|
-
require 'active_support/dependencies'
|
10
|
-
require 'lolita/errors'
|
11
|
-
# Require all ruby extensions
|
12
|
-
Dir["#{File.dirname(__FILE__)}/lolita/ruby_ext/**/*.*"].each do |path|
|
13
|
-
require path
|
14
|
-
end
|
15
|
-
|
16
|
-
module Lolita
|
17
|
-
autoload(:LazyLoader,'lolita/lazy_loader')
|
18
|
-
autoload(:VERSION,'lolita/version')
|
19
|
-
autoload(:ObservedArray,'lolita/observed_array')
|
20
|
-
autoload(:Builder,'lolita/builder')
|
21
|
-
autoload(:BaseConfiguration,'lolita/base_configuration')
|
22
|
-
module Adapter
|
23
|
-
autoload :AbstractAdapter, 'lolita/adapter/abstract_adapter'
|
24
|
-
autoload :ActiveRecord, 'lolita/adapter/active_record'
|
25
|
-
autoload :Mongoid, 'lolita/adapter/mongoid'
|
26
|
-
end
|
27
|
-
|
28
|
-
module DBI
|
29
|
-
autoload :Base, 'lolita/dbi/base'
|
30
|
-
end
|
31
|
-
|
32
|
-
module Hooks
|
33
|
-
require 'lolita/hooks/hooks'
|
34
|
-
include Lolita::Hooks::Hooks
|
35
|
-
autoload :Base, 'lolita/hooks/base'
|
36
|
-
autoload :Component, 'lolita/hooks/component'
|
37
|
-
end
|
38
|
-
|
39
|
-
module Configuration
|
40
|
-
autoload :
|
41
|
-
autoload :
|
42
|
-
autoload :
|
43
|
-
autoload :
|
44
|
-
autoload :
|
45
|
-
autoload :
|
46
|
-
autoload :
|
47
|
-
autoload :
|
48
|
-
autoload :
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
end
|
85
|
-
|
86
|
-
module
|
87
|
-
autoload :
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
autoload :
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
1
|
+
main_time=Time.now
|
2
|
+
|
3
|
+
$:<<File.dirname(__FILE__) unless $:.include?(File.dirname(__FILE__))
|
4
|
+
|
5
|
+
require 'abstract' #FIXME remove from gem
|
6
|
+
require 'active_support/core_ext/numeric/time'
|
7
|
+
require 'active_support/concern'
|
8
|
+
require 'active_support/callbacks'
|
9
|
+
require 'active_support/dependencies'
|
10
|
+
require 'lolita/errors'
|
11
|
+
# Require all ruby extensions
|
12
|
+
Dir["#{File.dirname(__FILE__)}/lolita/ruby_ext/**/*.*"].each do |path|
|
13
|
+
require path
|
14
|
+
end
|
15
|
+
|
16
|
+
module Lolita
|
17
|
+
autoload(:LazyLoader,'lolita/lazy_loader')
|
18
|
+
autoload(:VERSION,'lolita/version')
|
19
|
+
autoload(:ObservedArray,'lolita/observed_array')
|
20
|
+
autoload(:Builder,'lolita/builder')
|
21
|
+
autoload(:BaseConfiguration,'lolita/base_configuration')
|
22
|
+
module Adapter
|
23
|
+
autoload :AbstractAdapter, 'lolita/adapter/abstract_adapter'
|
24
|
+
autoload :ActiveRecord, 'lolita/adapter/active_record'
|
25
|
+
autoload :Mongoid, 'lolita/adapter/mongoid'
|
26
|
+
end
|
27
|
+
|
28
|
+
module DBI
|
29
|
+
autoload :Base, 'lolita/dbi/base'
|
30
|
+
end
|
31
|
+
|
32
|
+
module Hooks
|
33
|
+
require 'lolita/hooks/hooks'
|
34
|
+
include Lolita::Hooks::Hooks
|
35
|
+
autoload :Base, 'lolita/hooks/base'
|
36
|
+
autoload :Component, 'lolita/hooks/component'
|
37
|
+
end
|
38
|
+
|
39
|
+
module Configuration
|
40
|
+
autoload :Factory, 'lolita/configuration/factory'
|
41
|
+
autoload :Base, 'lolita/configuration/base'
|
42
|
+
autoload :Column, 'lolita/configuration/column'
|
43
|
+
autoload :Columns, 'lolita/configuration/columns'
|
44
|
+
autoload :Field, 'lolita/configuration/field'
|
45
|
+
autoload :FieldSet, 'lolita/configuration/field_set'
|
46
|
+
autoload :List, 'lolita/configuration/list'
|
47
|
+
autoload :Page, 'lolita/configuration/page'
|
48
|
+
autoload :Tab, 'lolita/configuration/tab'
|
49
|
+
autoload :Tabs, 'lolita/configuration/tabs'
|
50
|
+
|
51
|
+
["tab","field"].each do |type|
|
52
|
+
Dir["#{File.dirname(__FILE__)}/lolita/configuration/#{type}/**/*.*"].each do |path|
|
53
|
+
base_name=File.basename(path,".rb")
|
54
|
+
autoload :"#{base_name.capitalize}#{type.humanize}", "lolita/configuration/#{type}/#{base_name}"
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
|
59
|
+
def self.included(base)
|
60
|
+
base.class_eval do
|
61
|
+
extend ClassMethods
|
62
|
+
def lolita
|
63
|
+
self.class.lolita
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
module ClassMethods
|
69
|
+
def lolita(&block)
|
70
|
+
Lolita::LazyLoader.lazy_load(self,:@lolita,Lolita::Configuration::Base,self,&block)
|
71
|
+
end
|
72
|
+
def lolita=(value)
|
73
|
+
if value.is_a?(Lolita::Configuration::Base)
|
74
|
+
@lolita=value
|
75
|
+
else
|
76
|
+
raise ArgumentError.new("Only Lolita::Configuration::Base is acceptable.")
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
module Test
|
83
|
+
autoload :Matchers, 'lolita/test/matchers'
|
84
|
+
end
|
85
|
+
|
86
|
+
module Controllers
|
87
|
+
autoload :InternalHelpers, 'lolita/controllers/internal_helpers'
|
88
|
+
autoload :UserHelpers, 'lolita/controllers/user_helpers'
|
89
|
+
autoload :UrlHelpers, 'lolita/controllers/url_helpers'
|
90
|
+
autoload :ComponentHelpers, 'lolita/controllers/component_helpers'
|
91
|
+
autoload :ViewUserHelpers, 'lolita/controllers/view_user_helpers'
|
92
|
+
end
|
93
|
+
|
94
|
+
|
95
|
+
@@scopes={}
|
96
|
+
|
97
|
+
def self.scope name=nil
|
98
|
+
name||=scope_name
|
99
|
+
@@scopes[name]||=Lolita::BaseConfiguration.new(name)
|
100
|
+
@@scopes[name]
|
101
|
+
end
|
102
|
+
|
103
|
+
def self.setup
|
104
|
+
yield scope
|
105
|
+
end
|
106
|
+
|
107
|
+
def self.scope_name
|
108
|
+
:default
|
109
|
+
end
|
110
|
+
|
111
|
+
def self.root
|
112
|
+
@@root||=File.expand_path("#{__FILE__}/../..")
|
113
|
+
end
|
114
|
+
|
115
|
+
def self.app_root
|
116
|
+
@@app_root||=File.join(File.expand_path("#{__FILE__}/../.."),"app")
|
117
|
+
end
|
118
|
+
|
119
|
+
def self.method_missing method_name, *args, &block
|
120
|
+
scope.send(method_name,*args,&block)
|
121
|
+
end
|
122
|
+
|
123
|
+
module Generators
|
124
|
+
autoload :FileHelper, File.join(Lolita.root,"lib","generators","helpers","file_helper")
|
125
|
+
end
|
126
|
+
|
127
|
+
end
|
128
|
+
|
129
|
+
engine_time=Time.now
|
130
|
+
|
131
|
+
if defined?(Rails)
|
132
|
+
require 'lolita/rails/all'
|
133
|
+
end
|
134
|
+
|
135
|
+
puts "Lolita engine started in #{Time.at(Time.now-engine_time).strftime("%M:%S.%3N")}"
|
136
|
+
|
136
137
|
puts "Lolita started in #{Time.at(Time.now-main_time).strftime("%M:%S.%3N")}"
|
@@ -1,111 +1,111 @@
|
|
1
|
-
module Lolita
|
2
|
-
module Adapter
|
3
|
-
class ActiveRecord
|
4
|
-
include Lolita::Adapter::AbstractAdapter
|
5
|
-
|
6
|
-
attr_reader :dbi, :klass
|
7
|
-
def initialize(dbi)
|
8
|
-
@dbi=dbi
|
9
|
-
@klass=dbi.klass
|
10
|
-
end
|
11
|
-
|
12
|
-
def associations
|
13
|
-
klass.reflections
|
14
|
-
end
|
15
|
-
|
16
|
-
# Same as in mongoid
|
17
|
-
def associations_klass_names
|
18
|
-
names=[]
|
19
|
-
associations.each{|name,association|
|
20
|
-
names << association.class_name
|
21
|
-
}
|
22
|
-
names
|
23
|
-
end
|
24
|
-
|
25
|
-
def reflect_on_association(name)
|
26
|
-
klass.reflect_on_association(name)
|
27
|
-
end
|
28
|
-
|
29
|
-
def association_macro(association)
|
30
|
-
type=association.macro
|
31
|
-
case type
|
32
|
-
when :has_many
|
33
|
-
:many
|
34
|
-
when :has_one
|
35
|
-
:one
|
36
|
-
when :belongs_to
|
37
|
-
:one
|
38
|
-
when :has_and_belongs_to_many
|
39
|
-
:many
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
def association_class_name(association)
|
44
|
-
association.class_name
|
45
|
-
end
|
46
|
-
|
47
|
-
def fields
|
48
|
-
@fields||=self.klass.columns.collect{|column|
|
49
|
-
field_to_hash(column)
|
50
|
-
}.reject{|column|
|
51
|
-
column[:options][:primary]
|
52
|
-
}
|
53
|
-
@fields
|
54
|
-
end
|
55
|
-
|
56
|
-
def find_by_id(id)
|
57
|
-
self.klass.where(:id=>id).first
|
58
|
-
end
|
59
|
-
|
60
|
-
def find(*args)
|
61
|
-
self.klass.find(*args)
|
62
|
-
end
|
63
|
-
|
64
|
-
def paginate(opt={})
|
65
|
-
#FIXME depend on will_paginate
|
66
|
-
if order=opt.delete(:sort)
|
67
|
-
order.map{|c| c.join(" ")}.join(", ")
|
68
|
-
opt[:order_by]=order
|
69
|
-
end
|
70
|
-
self.klass.paginate(opt)
|
71
|
-
end
|
72
|
-
|
73
|
-
def db
|
74
|
-
self.klass.connection
|
75
|
-
end
|
76
|
-
|
77
|
-
def db_name
|
78
|
-
db.current_database
|
79
|
-
end
|
80
|
-
|
81
|
-
def collection
|
82
|
-
self.klass #FIXME not realy same as in mongoid
|
83
|
-
end
|
84
|
-
|
85
|
-
def collection_name
|
86
|
-
self.klass.table_name
|
87
|
-
end
|
88
|
-
|
89
|
-
def collections
|
90
|
-
self.klass #FIXME not realy same as in mongoid
|
91
|
-
end
|
92
|
-
|
93
|
-
def collection_names
|
94
|
-
self.klass.connection.select_all("show tables from #{db_name}").map{|r| r.values.first}
|
95
|
-
end
|
96
|
-
|
97
|
-
private
|
98
|
-
|
99
|
-
def field_to_hash(column)
|
100
|
-
{
|
101
|
-
:name=>column.name,
|
102
|
-
:type=>column.type.to_s,
|
103
|
-
:title=>column.name.to_s.humanize,
|
104
|
-
:options=>{
|
105
|
-
:primary=>column.primary
|
106
|
-
}
|
107
|
-
}
|
108
|
-
end
|
109
|
-
end
|
110
|
-
end
|
1
|
+
module Lolita
|
2
|
+
module Adapter
|
3
|
+
class ActiveRecord
|
4
|
+
include Lolita::Adapter::AbstractAdapter
|
5
|
+
|
6
|
+
attr_reader :dbi, :klass
|
7
|
+
def initialize(dbi)
|
8
|
+
@dbi=dbi
|
9
|
+
@klass=dbi.klass
|
10
|
+
end
|
11
|
+
|
12
|
+
def associations
|
13
|
+
klass.reflections
|
14
|
+
end
|
15
|
+
|
16
|
+
# Same as in mongoid
|
17
|
+
def associations_klass_names
|
18
|
+
names=[]
|
19
|
+
associations.each{|name,association|
|
20
|
+
names << association.class_name
|
21
|
+
}
|
22
|
+
names
|
23
|
+
end
|
24
|
+
|
25
|
+
def reflect_on_association(name)
|
26
|
+
klass.reflect_on_association(name)
|
27
|
+
end
|
28
|
+
|
29
|
+
def association_macro(association)
|
30
|
+
type=association.macro
|
31
|
+
case type
|
32
|
+
when :has_many
|
33
|
+
:many
|
34
|
+
when :has_one
|
35
|
+
:one
|
36
|
+
when :belongs_to
|
37
|
+
:one
|
38
|
+
when :has_and_belongs_to_many
|
39
|
+
:many
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def association_class_name(association)
|
44
|
+
association.class_name
|
45
|
+
end
|
46
|
+
|
47
|
+
def fields
|
48
|
+
@fields||=self.klass.columns.collect{|column|
|
49
|
+
field_to_hash(column)
|
50
|
+
}.reject{|column|
|
51
|
+
column[:options][:primary]
|
52
|
+
}
|
53
|
+
@fields
|
54
|
+
end
|
55
|
+
|
56
|
+
def find_by_id(id)
|
57
|
+
self.klass.where(:id=>id).first
|
58
|
+
end
|
59
|
+
|
60
|
+
def find(*args)
|
61
|
+
self.klass.find(*args)
|
62
|
+
end
|
63
|
+
|
64
|
+
def paginate(opt={})
|
65
|
+
#FIXME depend on will_paginate
|
66
|
+
if order=opt.delete(:sort)
|
67
|
+
order.map{|c| c.join(" ")}.join(", ")
|
68
|
+
opt[:order_by]=order
|
69
|
+
end
|
70
|
+
self.klass.paginate(opt)
|
71
|
+
end
|
72
|
+
|
73
|
+
def db
|
74
|
+
self.klass.connection
|
75
|
+
end
|
76
|
+
|
77
|
+
def db_name
|
78
|
+
db.current_database
|
79
|
+
end
|
80
|
+
|
81
|
+
def collection
|
82
|
+
self.klass #FIXME not realy same as in mongoid
|
83
|
+
end
|
84
|
+
|
85
|
+
def collection_name
|
86
|
+
self.klass.table_name
|
87
|
+
end
|
88
|
+
|
89
|
+
def collections
|
90
|
+
self.klass #FIXME not realy same as in mongoid
|
91
|
+
end
|
92
|
+
|
93
|
+
def collection_names
|
94
|
+
self.klass.connection.select_all("show tables from #{db_name}").map{|r| r.values.first}
|
95
|
+
end
|
96
|
+
|
97
|
+
private
|
98
|
+
|
99
|
+
def field_to_hash(column)
|
100
|
+
{
|
101
|
+
:name=>column.name,
|
102
|
+
:type=>column.type.to_s,
|
103
|
+
:title=>column.name.to_s.humanize,
|
104
|
+
:options=>{
|
105
|
+
:primary=>column.primary
|
106
|
+
}
|
107
|
+
}
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
111
|
end
|