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 CHANGED
@@ -15,7 +15,7 @@ module Devlin
15
15
 
16
16
  def scope(name)
17
17
  @scope ||= {}
18
- @scope[name.to_sym] ||= Scope.new(@params, &(self.class[name.to_sym]))
18
+ @scope[name.to_sym] ||= Scope.new(name, @params, &(self.class[name.to_sym]))
19
19
  @scope[name.to_sym]
20
20
  end
21
21
 
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
 
@@ -1,3 +1,3 @@
1
1
  module Devlin
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: devlin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: