buezli-api 0.1.0 → 0.1.1

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
  SHA256:
3
- metadata.gz: '094aa7cb35ecc313611cd66a86c777431461d8a8c8fdc9e6508f0a47d54bf5f5'
4
- data.tar.gz: e0750a2351cf57f9fe1911373c41fc4a04946da03ef24fbd0dc76225af289122
3
+ metadata.gz: 46c3eaef0c534db886a6f3536098616b004bc520629a00398651e3d9f4ae2427
4
+ data.tar.gz: 78cc040c2aaad5dc8e98b7795b056d2716293d1869eb08dcc2df085c4d35e82b
5
5
  SHA512:
6
- metadata.gz: 50b99f0e3d1aa8d1a9d5525f9aacbcb763347da6ad95835ea523794dfcb6020c22d72dd1bf812fb995142c4fa80342f51d5f5cf4483866cd2d2a3b2aab92bb91
7
- data.tar.gz: 97e5011a61ac35e4867fccbbf9e022435ad2636b31bd7c3888090942c36bd198a996e2a92eba9050dfe560a1531e519b5b5d84a136d509bc296090fd1645edec
6
+ metadata.gz: 4bb3820291636601435a7424404f455e2da6d20864920c4a030d1476cf70c670c0be6c66ac7e5b8d95c9bc448231f5a8a42ffded32312dd44346cd56ec24eb47
7
+ data.tar.gz: a9500ba6c2bffe3c20afcf3063f88d9493699226958b66c1f00aa46dfd08a702149a03a1e856b7003d46f6d33c8be4088b1c3ae911a897f78f439bd79b07b322
data/README.md CHANGED
@@ -49,7 +49,10 @@ client = Buezli::Api::Client.new(
49
49
  Schema-declared dates and timestamps become `Date` and `Time`. Decimal values
50
50
  remain strings and money remains a `cents`/`currency` hash, avoiding precision
51
51
  loss. Unknown record methods raise `NoMethodError`; declared but absent fields
52
- return `nil`.
52
+ return `nil`. Schema fields take precedence over client implementation details,
53
+ so an expanded `client` association is available as `record.client`. The
54
+ transport client used to build nested records is available separately as
55
+ `record.api_client`.
53
56
 
54
57
  ## Pagination and deltas
55
58
 
@@ -2,13 +2,14 @@ module Buezli
2
2
  module Api
3
3
  class Client
4
4
  class Record
5
- attr_reader :raw_attributes, :model_name, :client, :schema
5
+ attr_reader :raw_attributes, :model_name, :api_client, :schema
6
6
 
7
- def initialize(attributes:, model_name:, client:, schema:)
7
+ def initialize(attributes:, model_name:, schema:, api_client: nil, client: nil)
8
8
  @raw_attributes = (attributes || {}).with_indifferent_access
9
9
  @model_name = model_name
10
- @client = client
10
+ @api_client = api_client || client
11
11
  @schema = schema
12
+ raise ArgumentError, "api_client is required" unless @api_client
12
13
  end
13
14
 
14
15
  def id
@@ -55,9 +56,9 @@ module Buezli
55
56
 
56
57
  target_model = schema.association_class_name(model_name, name)
57
58
  if schema.association_collection?(model_name, name)
58
- Array(value).map { |attributes| client.build_record(target_model, attributes) }
59
+ Array(value).map { |attributes| api_client.build_record(target_model, attributes) }
59
60
  else
60
- client.build_record(target_model, value)
61
+ api_client.build_record(target_model, value)
61
62
  end
62
63
  end
63
64
 
@@ -17,7 +17,7 @@ module Buezli
17
17
  end
18
18
 
19
19
  def build_record(model_name, attributes)
20
- Record.new(attributes:, model_name:, client: self, schema:)
20
+ Record.new(attributes:, model_name:, api_client: self, schema:)
21
21
  end
22
22
 
23
23
  def inspect
@@ -1,5 +1,5 @@
1
1
  module Buezli
2
2
  module Api
3
- VERSION = "0.1.0"
3
+ VERSION = "0.1.1"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: buezli-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Codegestalt