rom-yesql 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/rom/yesql/relation/class_interface.rb +23 -0
- data/lib/rom/yesql/relation.rb +7 -17
- data/lib/rom/yesql/version.rb +1 -1
- data/rom-yesql.gemspec +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f4293c627ad37a7b9b012b49a36f7957ac649ca4
|
4
|
+
data.tar.gz: a0ac4b5a884ba148febda72f048e2a325d00c2d3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c085a2988882b35abf014416876b5d0cbabb0c2c2d0fd4f581e5da5e444905f5ad855b44507454b8b7a2ecbaa1ae5c676eb993981178cb4651adb08c242a6e0c
|
7
|
+
data.tar.gz: bdb4def07d5e252157069b770313928503b8264f327579549343e7a1216a5abc7fdbe5d92152ea1dc83a3f10d578a2e2bda0636fa5834f720ddfdcfd7d97ccc9
|
data/CHANGELOG.md
CHANGED
@@ -0,0 +1,23 @@
|
|
1
|
+
module ROM
|
2
|
+
module Yesql
|
3
|
+
class Relation < ROM::Relation
|
4
|
+
module ClassInterface
|
5
|
+
# Set dataset name for the relation class
|
6
|
+
#
|
7
|
+
# The class will be extended with queries registered under that name.
|
8
|
+
# By default dataset name is derived from the class name, which doesn't
|
9
|
+
# have to match they key under which its queries were registered
|
10
|
+
#
|
11
|
+
# @return [Symbol]
|
12
|
+
#
|
13
|
+
# @api public
|
14
|
+
def dataset(name = Undefined)
|
15
|
+
return @dataset if name == Undefined
|
16
|
+
@dataset = name
|
17
|
+
define_query_methods(self, Relation.queries[name] || {})
|
18
|
+
@dataset
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/rom/yesql/relation.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'rom/relation'
|
2
|
+
require 'rom/yesql/relation/class_interface'
|
2
3
|
|
3
4
|
module ROM
|
4
5
|
module Yesql
|
@@ -24,8 +25,12 @@ module ROM
|
|
24
25
|
#
|
25
26
|
# @api public
|
26
27
|
class Relation < ROM::Relation
|
28
|
+
extend ClassMacros
|
29
|
+
|
27
30
|
defines :query_proc
|
28
31
|
|
32
|
+
Materialized = Class.new(Relation)
|
33
|
+
|
29
34
|
# Extends a relation with query methods
|
30
35
|
#
|
31
36
|
# This will only kick in if the derived dataset name matches the key under
|
@@ -35,25 +40,10 @@ module ROM
|
|
35
40
|
# @api private
|
36
41
|
def self.inherited(klass)
|
37
42
|
super
|
43
|
+
klass.extend(ClassInterface)
|
38
44
|
define_query_methods(klass, queries[klass.dataset] || {})
|
39
45
|
end
|
40
46
|
|
41
|
-
# Set dataset name for the relation class
|
42
|
-
#
|
43
|
-
# The class will be extended with queries registered under that name.
|
44
|
-
# By default dataset name is derived from the class name, which doesn't
|
45
|
-
# have to match they key under which its queries were registered
|
46
|
-
#
|
47
|
-
# @return [Symbol]
|
48
|
-
#
|
49
|
-
# @api public
|
50
|
-
def self.dataset(name = Undefined)
|
51
|
-
return @dataset if name == Undefined
|
52
|
-
@dataset = name
|
53
|
-
define_query_methods(self, Relation.queries[name] || {})
|
54
|
-
@dataset
|
55
|
-
end
|
56
|
-
|
57
47
|
# Extend provided klass with query methods
|
58
48
|
#
|
59
49
|
# @param [Class] klass A relation class
|
@@ -64,7 +54,7 @@ module ROM
|
|
64
54
|
queries.each do |name, query|
|
65
55
|
klass.class_eval do
|
66
56
|
define_method(name) do |*args|
|
67
|
-
|
57
|
+
Materialized.new(dataset.read(query_proc.call(name, query, *args)))
|
68
58
|
end
|
69
59
|
end
|
70
60
|
end
|
data/lib/rom/yesql/version.rb
CHANGED
data/rom-yesql.gemspec
CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.add_runtime_dependency 'rom', '~> 0.6.0.
|
21
|
+
spec.add_runtime_dependency 'rom', '~> 0.6.0.rc1'
|
22
22
|
spec.add_runtime_dependency 'sequel', '~> 4.19.0'
|
23
23
|
spec.add_development_dependency "bundler"
|
24
24
|
spec.add_development_dependency "rake", "~> 10.0"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rom-yesql
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Piotr Solnica
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rom
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.6.0.
|
19
|
+
version: 0.6.0.rc1
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.6.0.
|
26
|
+
version: 0.6.0.rc1
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: sequel
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -89,6 +89,7 @@ files:
|
|
89
89
|
- lib/rom/yesql.rb
|
90
90
|
- lib/rom/yesql/dataset.rb
|
91
91
|
- lib/rom/yesql/relation.rb
|
92
|
+
- lib/rom/yesql/relation/class_interface.rb
|
92
93
|
- lib/rom/yesql/repository.rb
|
93
94
|
- lib/rom/yesql/version.rb
|
94
95
|
- log/.gitkeep
|
@@ -122,7 +123,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
122
123
|
version: '0'
|
123
124
|
requirements: []
|
124
125
|
rubyforge_project:
|
125
|
-
rubygems_version: 2.
|
126
|
+
rubygems_version: 2.4.5
|
126
127
|
signing_key:
|
127
128
|
specification_version: 4
|
128
129
|
summary: Yesql databases support for ROM
|
@@ -135,4 +136,3 @@ test_files:
|
|
135
136
|
- spec/shared/users_and_tasks.rb
|
136
137
|
- spec/spec_helper.rb
|
137
138
|
- spec/unit/rom/yesql/repository_spec.rb
|
138
|
-
has_rdoc:
|