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 +4 -4
- data/README.md +23 -1
- data/lib/lhs/concerns/record/relations.rb +1 -6
- data/lib/lhs/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ae5e5ef2a45b0f63f18f0c37081cbce3a0834c09
|
4
|
+
data.tar.gz: 02cc862febe0af3c26077abb6ae1c748e872480b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
|
data/lib/lhs/version.rb
CHANGED
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
|
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:
|
453
|
+
version: '0'
|
454
454
|
requirements:
|
455
455
|
- Ruby >= 2.3.0
|
456
456
|
rubyforge_project:
|