hanami-model 1.2.0.beta2 → 1.2.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 415e804149cf39d1ebe055779657e3bfcd77f8ed855be9dc9cef9c8a2b54813b
4
- data.tar.gz: bf05583974ef7fb33be8905c72b985ad968148ded2b1bd2f3b1b31193ef84c34
3
+ metadata.gz: 686f2bdfbd1a3d690fe52263f7bcde2966761bfab7309c99543c91429206c1d5
4
+ data.tar.gz: 1769c202b73a2131705ee7e4f52b3296f7a5769f6311fef139880b66733f90d2
5
5
  SHA512:
6
- metadata.gz: fec1e5fb2dccafd3d9d208707b4a5781ebc3e90946a566a7699c300ea736827cf599bcadb7431e8de4c130ec022147bb2a3f1ae4140285a5c92b24c6f8ff0258
7
- data.tar.gz: e0d01476d62c3e77d7a0133d0b0a4ecc94762c144e7c4bbb4531fe61e3e2dde274a3bc4156e89c3cfbb95fa3b377a0578ee6295a9af6ece5d10ced8b8bbf411a
6
+ metadata.gz: 9a35334766fe5e0c6aee8e49657e7559aef608b17a496605a7363e839fa3e7c99626616bdb9d963a89f310b8bdf03c59c92400d98987b0b65ea877620c7b36d2
7
+ data.tar.gz: 103f13b9e25a9ad7325da52a0ddb1ef0d1c041aa2f94aa9f229fa3f4971c8d6a3a4643a93906485bec1bd0dc32d8461c8ea5b759d4691271ef5a6870cbdacd9d
data/CHANGELOG.md CHANGED
@@ -1,6 +1,10 @@
1
1
  # Hanami::Model
2
2
  A persistence layer for Hanami
3
3
 
4
+ ## v1.2.0.rc1 - 2018-03-30
5
+ ### Fixed
6
+ - [Marcello Rocha & Luca Guidi] Ensure repository relations to access database attributes via `#[]` (eg. `projects[:name].ilike("Hanami")`)
7
+
4
8
  ## v1.2.0.beta2 - 2018-03-23
5
9
 
6
10
  ## v1.2.0.beta1 - 2018-02-28
data/README.md CHANGED
@@ -242,7 +242,7 @@ class UserRepository < Hanami::Repository
242
242
  end
243
243
 
244
244
  Hanami::Model.configure do
245
- adapter :sql, uri: 'postgresql://localhost/bookshelf'
245
+ adapter :sql, 'postgresql://localhost/bookshelf'
246
246
  end.load!
247
247
 
248
248
  repository = UserRepository.new
data/hanami-model.gemspec CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
18
18
  spec.require_paths = ['lib']
19
19
  spec.required_ruby_version = '>= 2.3.0'
20
20
 
21
- spec.add_runtime_dependency 'hanami-utils', '1.2.0.beta2'
21
+ spec.add_runtime_dependency 'hanami-utils', '1.2.0.rc1'
22
22
  spec.add_runtime_dependency 'rom', '~> 3.3', '>= 3.3.3'
23
23
  spec.add_runtime_dependency 'rom-sql', '~> 1.3', '>= 1.3.5'
24
24
  spec.add_runtime_dependency 'rom-repository', '~> 1.4'
@@ -112,5 +112,11 @@ module Hanami
112
112
  # @since 1.0.0
113
113
  class MissingPrimaryKeyError < Error
114
114
  end
115
+
116
+ # Unknown attribute error
117
+ #
118
+ # @since 1.2.0
119
+ class UnknownAttributeError < Error
120
+ end
115
121
  end
116
122
  end
@@ -26,8 +26,34 @@ module Hanami
26
26
  # @since 1.0.0
27
27
  # @api private
28
28
  def initialize(relation)
29
+ @relation = relation
29
30
  super(relation.as(self.class.mapper_name))
30
31
  end
32
+
33
+ # Access low level relation's attribute
34
+ #
35
+ # @param attribute [Symbol] the attribute name
36
+ #
37
+ # @return [ROM::SQL::Attribute] the attribute
38
+ #
39
+ # @raises [Hanami::Model::UnknownAttributeError] if the attribute cannot be found
40
+ #
41
+ # @since 1.2.0
42
+ #
43
+ # @example
44
+ # class UserRepository < Hanami::Repository
45
+ # def by_matching_name(name)
46
+ # users
47
+ # .where(users[:name].ilike(name))
48
+ # .map_to(User)
49
+ # .to_a
50
+ # end
51
+ # end
52
+ def [](attribute)
53
+ @relation[attribute]
54
+ rescue KeyError => e
55
+ raise UnknownAttributeError.new(e.message)
56
+ end
31
57
  end
32
58
  end
33
59
  end
@@ -3,6 +3,6 @@ module Hanami
3
3
  # Defines the version
4
4
  #
5
5
  # @since 0.1.0
6
- VERSION = '1.2.0.beta2'.freeze
6
+ VERSION = '1.2.0.rc1'.freeze
7
7
  end
8
8
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hanami-model
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0.beta2
4
+ version: 1.2.0.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luca Guidi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-03-23 00:00:00.000000000 Z
11
+ date: 2018-03-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hanami-utils
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 1.2.0.beta2
19
+ version: 1.2.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: 1.2.0.beta2
26
+ version: 1.2.0.rc1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rom
29
29
  requirement: !ruby/object:Gem::Requirement