devlin 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/devlin/base.rb +1 -1
- data/lib/devlin/column.rb +6 -0
- data/lib/devlin/query.rb +2 -1
- data/lib/devlin/scope.rb +5 -2
- data/lib/devlin/version.rb +1 -1
- metadata +1 -1
data/lib/devlin/base.rb
CHANGED
data/lib/devlin/column.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
module Devlin
|
2
2
|
class Column
|
3
|
+
attr_reader :name, :config
|
4
|
+
|
3
5
|
def initialize(name, config, *args)
|
4
6
|
@name = name
|
5
7
|
@config = config
|
@@ -22,6 +24,10 @@ module Devlin
|
|
22
24
|
end
|
23
25
|
end
|
24
26
|
|
27
|
+
def human_attribute_name
|
28
|
+
I18n.t(self.name, scope[:devlin, config[:scope].name])
|
29
|
+
end
|
30
|
+
|
25
31
|
def arguments
|
26
32
|
@arguments
|
27
33
|
end
|
data/lib/devlin/query.rb
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
module Devlin
|
2
2
|
class Query
|
3
|
-
attr_reader :query, :scope
|
3
|
+
attr_reader :query, :scope, :scope_name
|
4
4
|
|
5
5
|
def initialize(parent, q)
|
6
6
|
@parent = parent
|
7
7
|
@query = YAML.load(q)
|
8
8
|
@scope = parent.scope(query['scope'])
|
9
|
+
@scope_name = query['scope']
|
9
10
|
@select = query['select']
|
10
11
|
@conditions = query['conditions']
|
11
12
|
@group = query['group']
|
data/lib/devlin/scope.rb
CHANGED
@@ -20,9 +20,11 @@ module Devlin
|
|
20
20
|
end
|
21
21
|
|
22
22
|
attr_accessor :relation
|
23
|
+
attr_reader :name
|
23
24
|
|
24
|
-
def initialize(params, &block)
|
25
|
+
def initialize(name, params, &block)
|
25
26
|
Config.new(self, params, &block)
|
27
|
+
@name = name
|
26
28
|
end
|
27
29
|
|
28
30
|
# add a column definition to the scope
|
@@ -30,7 +32,8 @@ module Devlin
|
|
30
32
|
@columns ||= {}
|
31
33
|
@columns[name.to_sym] = Column.new(name, {
|
32
34
|
definition: definition,
|
33
|
-
getter: block
|
35
|
+
getter: block,
|
36
|
+
scope: self
|
34
37
|
}, *args)
|
35
38
|
end
|
36
39
|
|
data/lib/devlin/version.rb
CHANGED