lhs 15.4.0.pre.hasone.1 → 15.4.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d100c6bf4ca9836392166b4aab5005e069f1bea8
4
- data.tar.gz: f7175a8ae0a1a788a76613ed3f5005f09dfb5097
3
+ metadata.gz: ae5e5ef2a45b0f63f18f0c37081cbce3a0834c09
4
+ data.tar.gz: 02cc862febe0af3c26077abb6ae1c748e872480b
5
5
  SHA512:
6
- metadata.gz: 9a3dd07fea9af559e69dd527cc84d212c98a64dadfe6a840c3af4e3488563bc8da793baf542c6c5ed2d94a48125b3526462a55f99e249d7d3941d2de46a56f93
7
- data.tar.gz: 17093f4ad5b922c5370cd5a37846b352288fcc73e2267fcdeb6b99416e1a10822e1078a56c3613db251b9df88d46ee0d6241a68c5f2072efc4ec1d08f3510b56
6
+ metadata.gz: aa2d6b4e45f4082f78a1a1c6d8290571866216d5b8c9ac7fc480578044eea7fb15989d2bafd11c52a104f39c909957ac2169f39b0f96ca4fab47977dfbbc0e9e
7
+ data.tar.gz: 821d13c8b9bb5d10f073c885eaba26580e712c287ee1ec22b538f075aff1f175db7300ed082be1d370a124d2d82789945f0d5b3f97a39fedfce5bfa508c4ef7f
data/README.md CHANGED
@@ -303,8 +303,9 @@ Even though, nested data is automatically casted when accessed, see: [Nested rec
303
303
 
304
304
  As those records also don't have an href, nested records can not be casted automatically, when accessed.
305
305
 
306
- Those kind of relations, you can still configure manually:
306
+ Those kind of relations, you can still configure manually, using `has_many` and `has_one`:
307
307
 
308
+ ### Relations
308
309
  ```ruby
309
310
 
310
311
  class Location < LHS::Record
@@ -326,6 +327,27 @@ Location.find(1).listings.first.supported? # true
326
327
 
327
328
  ```
328
329
 
330
+ ```ruby
331
+
332
+ class Transaction < LHS::Record
333
+
334
+ endpoint 'http://myservice/transaction/{id}'
335
+
336
+ has_one :user
337
+
338
+ end
339
+
340
+ class User < LHS::Record
341
+
342
+ def email
343
+ self[:email_address]
344
+ end
345
+ end
346
+
347
+ Transaction.find(1).user.email_address # steve@local.ch
348
+
349
+ ```
350
+
329
351
  ### Options
330
352
 
331
353
  In case you have to configure relations, the following relation options are available:
@@ -12,18 +12,13 @@ class LHS::Record
12
12
  end
13
13
 
14
14
  module ClassMethods
15
-
16
15
  def has_many(*options)
17
16
  name = options[0]
18
17
  options = options[1] || {}
19
18
  _relations[name] = { record_class_name: options.fetch(:class_name, name.to_s.singularize.classify) }
20
19
  end
21
20
 
22
- def has_one(*options)
23
- name = options[0]
24
- options = options[1] || {}
25
- _relations[name] = { record_class_name: options.fetch(:class_name, name.to_s.singularize.classify) }
26
- end
21
+ alias has_one has_many
27
22
  end
28
23
  end
29
24
  end
@@ -1,3 +1,3 @@
1
1
  module LHS
2
- VERSION = '15.4.0.pre.hasone.1'
2
+ VERSION = '15.4.0'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lhs
3
3
  version: !ruby/object:Gem::Version
4
- version: 15.4.0.pre.hasone.1
4
+ version: 15.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - https://github.com/local-ch/lhs/graphs/contributors
@@ -448,9 +448,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
448
448
  version: 2.3.0
449
449
  required_rubygems_version: !ruby/object:Gem::Requirement
450
450
  requirements:
451
- - - ">"
451
+ - - ">="
452
452
  - !ruby/object:Gem::Version
453
- version: 1.3.1
453
+ version: '0'
454
454
  requirements:
455
455
  - Ruby >= 2.3.0
456
456
  rubyforge_project: