gecko-ruby 0.9.1 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (103) hide show
  1. checksums.yaml +4 -4
  2. data/.github/config/rubocop_linter_action.yml +7 -0
  3. data/.github/workflows/testing.yml +26 -0
  4. data/.rubocop.yml +23 -16
  5. data/CHANGELOG.md +4 -0
  6. data/Gemfile +2 -0
  7. data/README.md +1 -1
  8. data/Rakefile +3 -1
  9. data/gecko-ruby.gemspec +11 -10
  10. data/generate.thor +4 -1
  11. data/lib/gecko-ruby.rb +2 -0
  12. data/lib/gecko.rb +2 -0
  13. data/lib/gecko/client.rb +16 -14
  14. data/lib/gecko/ext/liquid_compat.rb +10 -10
  15. data/lib/gecko/ext/log_subscriber.rb +6 -6
  16. data/lib/gecko/helpers/association_helper.rb +11 -9
  17. data/lib/gecko/helpers/inspection_helper.rb +4 -2
  18. data/lib/gecko/helpers/record_helper.rb +2 -0
  19. data/lib/gecko/helpers/serialization_helper.rb +5 -1
  20. data/lib/gecko/helpers/validation_helper.rb +3 -1
  21. data/lib/gecko/record/account.rb +3 -1
  22. data/lib/gecko/record/address.rb +2 -0
  23. data/lib/gecko/record/base.rb +5 -3
  24. data/lib/gecko/record/base_adapter.rb +23 -18
  25. data/lib/gecko/record/company.rb +2 -0
  26. data/lib/gecko/record/contact.rb +2 -0
  27. data/lib/gecko/record/currency.rb +2 -0
  28. data/lib/gecko/record/exceptions.rb +2 -0
  29. data/lib/gecko/record/fulfillment.rb +2 -0
  30. data/lib/gecko/record/fulfillment_line_item.rb +2 -1
  31. data/lib/gecko/record/image.rb +13 -8
  32. data/lib/gecko/record/invoice.rb +5 -1
  33. data/lib/gecko/record/invoice_line_item.rb +2 -1
  34. data/lib/gecko/record/location.rb +2 -0
  35. data/lib/gecko/record/note.rb +2 -0
  36. data/lib/gecko/record/order.rb +2 -0
  37. data/lib/gecko/record/order_line_item.rb +3 -0
  38. data/lib/gecko/record/payment_term.rb +2 -1
  39. data/lib/gecko/record/product.rb +4 -0
  40. data/lib/gecko/record/purchase_order.rb +2 -1
  41. data/lib/gecko/record/purchase_order_line_item.rb +2 -1
  42. data/lib/gecko/record/tax_type.rb +2 -1
  43. data/lib/gecko/record/user.rb +3 -1
  44. data/lib/gecko/record/variant.rb +9 -7
  45. data/lib/gecko/record/webhook.rb +3 -1
  46. data/lib/gecko/version.rb +3 -1
  47. data/test/client_test.rb +4 -2
  48. data/test/fixtures/vcr_cassettes/images.yml +1 -1
  49. data/test/gecko_test.rb +2 -0
  50. data/test/helpers/association_helper_test.rb +7 -5
  51. data/test/helpers/inspection_helper_test.rb +6 -4
  52. data/test/helpers/serialization_helper_test.rb +16 -14
  53. data/test/helpers/validation_helper_test.rb +3 -1
  54. data/test/record/account_adapter_test.rb +2 -0
  55. data/test/record/address_adapter_test.rb +2 -0
  56. data/test/record/address_test.rb +2 -0
  57. data/test/record/company_adapter_test.rb +2 -0
  58. data/test/record/company_test.rb +2 -0
  59. data/test/record/contact_adapter_test.rb +2 -0
  60. data/test/record/contact_test.rb +3 -1
  61. data/test/record/currency_adapter_test.rb +2 -0
  62. data/test/record/currency_test.rb +2 -0
  63. data/test/record/fulfillment_adapter_test.rb +2 -0
  64. data/test/record/fulfillment_line_item_adapter_test.rb +2 -0
  65. data/test/record/fulfillment_line_item_test.rb +2 -0
  66. data/test/record/fulfillment_test.rb +4 -2
  67. data/test/record/image_adapter_test.rb +2 -0
  68. data/test/record/image_test.rb +18 -0
  69. data/test/record/invoice_adapter_test.rb +2 -0
  70. data/test/record/invoice_line_item_adapter_test.rb +2 -0
  71. data/test/record/invoice_line_item_test.rb +2 -0
  72. data/test/record/invoice_test.rb +2 -0
  73. data/test/record/location_adapter_test.rb +2 -0
  74. data/test/record/location_test.rb +2 -0
  75. data/test/record/note_test.rb +2 -0
  76. data/test/record/order_adapter_test.rb +2 -0
  77. data/test/record/order_line_item_adapter_test.rb +2 -0
  78. data/test/record/order_line_item_test.rb +2 -0
  79. data/test/record/order_test.rb +2 -0
  80. data/test/record/payment_term_adapter_test.rb +2 -0
  81. data/test/record/payment_term_test.rb +2 -0
  82. data/test/record/product_adapter_test.rb +2 -0
  83. data/test/record/product_test.rb +2 -0
  84. data/test/record/purchase_order_adapter_test.rb +2 -0
  85. data/test/record/purchase_order_line_item_adapter_test.rb +2 -0
  86. data/test/record/purchase_order_line_item_test.rb +2 -0
  87. data/test/record/purchase_order_test.rb +2 -0
  88. data/test/record/tax_type_adapter_test.rb +2 -0
  89. data/test/record/tax_type_test.rb +2 -0
  90. data/test/record/user_adapter_test.rb +2 -0
  91. data/test/record/user_test.rb +2 -0
  92. data/test/record/variant_adapter_test.rb +2 -0
  93. data/test/record/variant_test.rb +6 -4
  94. data/test/record/webhook_test.rb +2 -0
  95. data/test/support/let.rb +2 -0
  96. data/test/support/shared_adapter_examples.rb +34 -30
  97. data/test/support/shared_record_examples.rb +3 -1
  98. data/test/support/shared_sideloaded_data_parsing_examples.rb +2 -1
  99. data/test/support/testing_adapter.rb +2 -0
  100. data/test/support/vcr_support.rb +2 -0
  101. data/test/test_helper.rb +2 -0
  102. metadata +24 -23
  103. data/.travis.yml +0 -8
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a9a15bbf88b9aebbbc1e5a7c0724657f445db9da7182986efa59340a158ab476
4
- data.tar.gz: 3528a3d9d2478ec1bece4ee9ca13cd195a3a7ae19535456379c27cc10c79674a
3
+ metadata.gz: 0eb1c65172dc30ba079cc816764f1329d5a2bf1f8835b425b9aebcaee117230f
4
+ data.tar.gz: c2003acbfe9bc3c7c80497610ae7e4193937d52e7a2e9671f5d9bd38309e8208
5
5
  SHA512:
6
- metadata.gz: 6c2e0c53ae78878be8c6ed89fc0ae48286bc0242332b0b914f6a0c8696314f1544dca0213305683a8d4966f42832d0e710d91ef8ce48bb10919c0fb3724ef5c9
7
- data.tar.gz: a80856cebaf487f55918709bd2c8bda50aa5c49e24fd6a213b42a1c95a9b3577341b2b7ed2965a2c674ebe19ec5846bea7bb1da6d16610356bede2a98fffc3fe
6
+ metadata.gz: 5e43314e5da9020c7b7440585205aabd7e37342bd0a25a8c56025c6abf2416e347ed591a3293123c5d1934c929c90e64a14cfe6eaa0f902c188943276db1c9c2
7
+ data.tar.gz: 1c831c98c2b1cc0cdec7a9fe2ba6c1f70e942eef2b70c201892f124cceee21b2c0ff6d08ea4714119b40d2d0cc1b993258991f92998aac8f066c78924e8e7e9b
@@ -0,0 +1,7 @@
1
+ ---
2
+ check_name: 'Rubocop Results'
3
+ check_scope: 'modified'
4
+ versions:
5
+ - rubocop
6
+ - rubocop-minitest
7
+ - rubocop-performance
@@ -0,0 +1,26 @@
1
+ ---
2
+ name: Ruby Tests
3
+
4
+ 'on': [push, pull_request]
5
+
6
+ jobs:
7
+ build:
8
+ runs-on: ubuntu-latest
9
+ strategy:
10
+ matrix:
11
+ ruby: ['2.4', '2.5', '2.6', '2.7']
12
+ name: Ruby ${{ matrix.ruby }}
13
+ steps:
14
+ - uses: actions/checkout@v2
15
+ - uses: actions/setup-ruby@v1
16
+ with:
17
+ ruby-version: ${{ matrix.ruby }}
18
+ - name: Run Tests
19
+ run: |
20
+ gem install bundler --no-document
21
+ bundle install --jobs 4 --retry 3
22
+ bundle exec rake
23
+ - name: Rubocop
24
+ uses: andrewmcodes/rubocop-linter-action@v3.1.0
25
+ env:
26
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -1,5 +1,8 @@
1
1
  AllCops:
2
2
  DisplayCopNames: true
3
+ Exclude:
4
+ - 'bin/*'
5
+ - 'generate.thor'
3
6
 
4
7
  # class Example
5
8
  # ...
@@ -9,33 +12,34 @@ AllCops:
9
12
  Layout/AccessModifierIndentation:
10
13
  EnforcedStyle: outdent
11
14
 
12
- Style/Blocks:
13
- Enabled: false
14
-
15
- # Allows foo(bar: baz)
16
- Style/BracesAroundHashParameters:
17
- Enabled: false
18
-
19
15
  Layout/DotPosition:
20
16
  EnforcedStyle: leading
21
17
 
22
- Layout/IndentHash:
18
+ Layout/FirstHashElementIndentation:
23
19
  EnforcedStyle: consistent
24
20
 
25
- Metrics/LineLength:
21
+ Layout/LineLength:
26
22
  Max: 120
27
23
 
28
- Style/RedundantSelf:
29
- Enabled: false
24
+ Layout/HashAlignment:
25
+ EnforcedColonStyle: table
30
26
 
31
- # We like neatly-aligned code
32
- Layout/SpaceBeforeFirstArg:
27
+ Metrics/AbcSize:
28
+ Exclude:
29
+ - 'test/**/*.rb'
30
+
31
+ Naming/FileName:
32
+ Exclude:
33
+ - 'lib/gecko-ruby.rb'
34
+
35
+ Naming/PredicateName:
33
36
  Enabled: false
34
37
 
35
- Layout/SpaceAroundEqualsInParameterDefault:
38
+ Naming/AccessorMethodName:
36
39
  Enabled: false
37
40
 
38
- Layout/SpaceInsideHashLiteralBraces:
41
+ # We like neatly-aligned code
42
+ Layout/SpaceBeforeFirstArg:
39
43
  Enabled: false
40
44
 
41
45
  # Allow single or double quotes
@@ -63,7 +67,10 @@ Layout/MultilineOperationIndentation:
63
67
  Enabled: false
64
68
 
65
69
  Style/ClassAndModuleChildren:
66
- EnforcedStyle: compact
70
+ Enabled: false
71
+
72
+ Style/Documentation:
73
+ Enabled: false
67
74
 
68
75
  Style/DoubleNegation:
69
76
  Enabled: false
@@ -1,3 +1,7 @@
1
+ ## 0.10.0 (2020-0406)
2
+ - Add extra delegated attributes to invoice record
3
+ - [BREAKING] Update Image record to latest API with product and multiple variant support
4
+
1
5
  ## 0.9.1 (2019-07-29)
2
6
  - Fix issue with LiquidCompat that broke during refactor
3
7
 
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
 
3
5
  # Specify your gem's dependencies in gecko.gemspec
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # TradeGecko RubyGem [![Build Status](https://travis-ci.org/tradegecko/gecko.png)](https://travis-ci.org/tradegecko/gecko) [![Code Climate](https://codeclimate.com/github/tradegecko/gecko.png)](https://codeclimate.com/github/tradegecko/gecko)
1
+ # TradeGecko RubyGem ![Build Status](https://github.com/tradegecko/gecko/workflows/Ruby%20Tests/badge.svg) [![Code Climate](https://codeclimate.com/github/tradegecko/gecko.png)](https://codeclimate.com/github/tradegecko/gecko)
2
2
  The official TradeGecko API RubyGem
3
3
 
4
4
  ## Introduction
data/Rakefile CHANGED
@@ -1,8 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "bundler/gem_tasks"
2
4
 
3
5
  require 'rake/testtask'
4
6
 
5
- task :default => [:test]
7
+ task default: [:test]
6
8
 
7
9
  Rake::TestTask.new do |t|
8
10
  t.libs << 'test'
@@ -1,5 +1,6 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('lib', __dir__)
3
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
5
  require 'gecko/version'
5
6
 
@@ -8,7 +9,7 @@ Gem::Specification.new do |spec|
8
9
  spec.version = Gecko::VERSION
9
10
  spec.authors = ["Bradley Priest"]
10
11
  spec.email = ['bradley@tradegecko.com']
11
- spec.description = %q{A Ruby interface to the TradeGecko API.}
12
+ spec.description = 'A Ruby interface to the TradeGecko API.'
12
13
  spec.summary = spec.description
13
14
  spec.homepage = 'https://github.com/tradegecko/gecko/'
14
15
  spec.license = 'MIT'
@@ -19,17 +20,17 @@ Gem::Specification.new do |spec|
19
20
  spec.require_paths = ["lib"]
20
21
 
21
22
  spec.add_development_dependency "bundler"
22
- spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "dotenv"
23
24
  spec.add_development_dependency "minitest"
24
- spec.add_development_dependency "vcr"
25
- spec.add_development_dependency "webmock"
26
25
  spec.add_development_dependency "mocha"
27
- spec.add_development_dependency "timecop"
28
- spec.add_development_dependency "dotenv"
29
- spec.add_development_dependency "thor"
30
26
  spec.add_development_dependency "pry"
27
+ spec.add_development_dependency "rake"
28
+ spec.add_development_dependency "thor"
29
+ spec.add_development_dependency "timecop"
30
+ spec.add_development_dependency "vcr"
31
+ spec.add_development_dependency "webmock"
31
32
 
33
+ spec.add_dependency "activesupport"
32
34
  spec.add_dependency "oauth2", "> 1.1.0"
33
35
  spec.add_dependency "virtus"
34
- spec.add_dependency "activesupport"
35
36
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'active_support/inflector'
2
4
  class Generate < Thor
3
5
  include Thor::Actions
@@ -7,7 +9,7 @@ class Generate < Thor
7
9
  @model_name = model_name
8
10
  @file_name = model_name.underscore
9
11
  @plural = ask "What is the underscore plural of #{@model_name}? (#{@file_name}s):"
10
- @plural = @plural.to_s.length > 0 ? @plural : @file_name + "s"
12
+ @plural = !@plural.to_s.empty? ? @plural : @file_name + "s"
11
13
  create_file "lib/gecko/record/#{@file_name}.rb", model_template
12
14
  create_file "test/record/#{@file_name}_adapter_test.rb", test_adapter_template
13
15
  create_file "test/record/#{@file_name}_test.rb", test_template
@@ -16,6 +18,7 @@ class Generate < Thor
16
18
  end
17
19
 
18
20
  private
21
+
19
22
  def default_plural?
20
23
  @plural == @file_name + "s"
21
24
  end
@@ -1 +1,3 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'gecko'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'virtus'
2
4
  require 'active_support/inflector'
3
5
  require 'active_support/notifications'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'faraday'
2
4
  require 'oauth2/version'
3
5
  require 'gecko/version'
@@ -57,7 +59,7 @@ module Gecko
57
59
  # @return [undefined]
58
60
  #
59
61
  # @api private
60
- def initialize(client_id, client_secret, options={})
62
+ def initialize(client_id, client_secret, options = {})
61
63
  setup_oauth_client(client_id, client_secret, options)
62
64
  end
63
65
 
@@ -107,29 +109,29 @@ module Gecko
107
109
  #
108
110
  # @api private
109
111
  def adapter_for(klass_name)
110
- self.public_send(klass_name.to_sym)
112
+ public_send(klass_name.to_sym)
113
+ end
114
+
115
+ def self.default_headers
116
+ {
117
+ 'User-Agent' => ["Gecko/#{Gecko::VERSION}",
118
+ "OAuth2/#{OAuth2::Version}",
119
+ "Faraday/#{Faraday::VERSION}",
120
+ "Ruby/#{RUBY_VERSION}"].join(' ')
121
+ }
111
122
  end
112
123
 
113
124
  private
114
125
 
115
126
  def setup_oauth_client(client_id, client_secret, options)
116
127
  defaults = {
117
- site: 'https://api.tradegecko.com',
118
- authorize_url: 'https://go.tradegecko.com/oauth/authorize',
128
+ site: 'https://api.tradegecko.com',
129
+ authorize_url: 'https://go.tradegecko.com/oauth/authorize',
119
130
  connection_opts: {
120
- headers: self.class.default_headers
131
+ headers: self.class.default_headers
121
132
  }
122
133
  }
123
134
  @oauth_client = OAuth2::Client.new(client_id, client_secret, defaults.merge(options))
124
135
  end
125
-
126
- def self.default_headers
127
- {
128
- 'User-Agent' => ["Gecko/#{Gecko::VERSION}",
129
- "OAuth2/#{OAuth2::Version.to_s}",
130
- "Faraday/#{Faraday::VERSION}",
131
- "Ruby/#{RUBY_VERSION}"].join(' ')
132
- }
133
- end
134
136
  end
135
137
  end
@@ -56,20 +56,20 @@ module Gecko
56
56
 
57
57
  ## Override Liquid::Drop#invoke_drop to also check method arity
58
58
  def invoke_drop(method_or_key)
59
- if self.invokable_methods.include?(method_or_key.to_s) && self.method_arity(method_or_key.to_sym) <= 0
60
- self.public_send(method_or_key)
61
- end
59
+ return unless invokable_methods.include?(method_or_key.to_s) && method_arity(method_or_key.to_sym) <= 0
60
+
61
+ public_send(method_or_key)
62
62
  end
63
63
 
64
- alias_method :[], :invoke_drop
64
+ alias [] invoke_drop
65
65
 
66
66
  ## Override Liquid::Drop#invokable_methods to add extra checks
67
67
  def invokable_methods
68
68
  @invokable_methods ||= begin
69
- blacklist = Gecko::Record::Base.public_instance_methods + Liquid::Drop.public_instance_methods
70
- blacklist -= [:to_liquid, :id, :created_at, :updated_at]
71
- whitelist = self.public_methods + @delegate.public_methods
72
- available_methods = (whitelist - blacklist).map(&:to_s)
69
+ denylist = Gecko::Record::Base.public_instance_methods + Liquid::Drop.public_instance_methods
70
+ denylist -= %i[to_liquid id created_at updated_at]
71
+ allowlist = public_methods + @delegate.public_methods
72
+ available_methods = (allowlist - denylist).map(&:to_s)
73
73
  available_methods.reject! { |method_name| method_name.ends_with?("=") }
74
74
  Set.new(available_methods)
75
75
  end
@@ -78,8 +78,8 @@ module Gecko
78
78
  protected
79
79
 
80
80
  def method_arity(method_name)
81
- if self.methods.include?(method_name)
82
- self.method(method_name).arity
81
+ if methods.include?(method_name)
82
+ method(method_name).arity
83
83
  else
84
84
  @delegate.method(method_name).arity
85
85
  end
@@ -13,7 +13,7 @@ class GeckoLogSubscriber < ActiveSupport::LogSubscriber
13
13
  @odd = false
14
14
  end
15
15
 
16
- def request(event)
16
+ def request(event) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
17
17
  RequestStore.store[ENV_KEY] = []
18
18
  payload = event.payload
19
19
 
@@ -27,11 +27,11 @@ class GeckoLogSubscriber < ActiveSupport::LogSubscriber
27
27
  name = "#{payload[:model_class]} Load (#{event.duration.round(1)}ms)"
28
28
  query = "#{payload[:verb].to_s.upcase} /#{request_path}"
29
29
 
30
- if odd?
31
- name = color(name, CYAN, true)
32
- else
33
- name = color(name, MAGENTA, true)
34
- end
30
+ name = if odd?
31
+ color(name, CYAN, true)
32
+ else
33
+ color(name, MAGENTA, true)
34
+ end
35
35
 
36
36
  query = color(query, nil, true)
37
37
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Gecko
2
4
  module Helpers
3
5
  # Helper for has_many/belongs_to relationships
@@ -24,7 +26,7 @@ module Gecko
24
26
  # @return [undefined]
25
27
  #
26
28
  # @api public
27
- def belongs_to(model_name, options={})
29
+ def belongs_to(model_name, options = {})
28
30
  class_name = options[:class_name] || model_name.to_s.classify
29
31
  foreign_key = model_name.to_s.foreign_key.to_sym
30
32
 
@@ -55,20 +57,20 @@ module Gecko
55
57
  # @return [undefined]
56
58
  #
57
59
  # @api public
58
- def has_many(association_name, options={})
60
+ def has_many(association_name, options = {}) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
59
61
  model_name = association_name.to_s.singularize
60
62
  class_name = options[:class_name] || model_name.classify
61
63
  foreign_key = model_name.foreign_key.pluralize.to_sym
62
64
  readonly = options.key?(:readonly) ? options[:readonly] : true
63
65
 
64
- define_method association_name do
66
+ define_method association_name do # rubocop:disable Metrics/MethodLength
65
67
  collection_proxies[association_name] ||= begin
66
- ids = self.attributes[foreign_key]
67
- if ids.any?
68
- collection = @client.adapter_for(class_name).find_many(ids)
69
- else
70
- collection = []
71
- end
68
+ ids = attributes[foreign_key]
69
+ collection = if ids.any?
70
+ @client.adapter_for(class_name).find_many(ids)
71
+ else
72
+ []
73
+ end
72
74
 
73
75
  build_collection_proxy(collection, {
74
76
  embedded: options[:embedded],
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Gecko
2
4
  module Helpers
3
5
  # Helper for providing custom #inspect values to Records
@@ -39,9 +41,9 @@ module Gecko
39
41
  if value.is_a?(String) && value.length > 50
40
42
  "#{value[0..50]}...".inspect
41
43
  elsif value.is_a?(DateTime) || value.is_a?(Time)
42
- %("#{value.strftime("%Y-%m-%d %H:%M:%S")}")
44
+ %("#{value.strftime('%Y-%m-%d %H:%M:%S')}")
43
45
  elsif value.is_a?(Date)
44
- %("#{value.strftime("%Y-%m-%d")}")
46
+ %("#{value.strftime('%Y-%m-%d')}")
45
47
  else
46
48
  value.inspect
47
49
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Gecko
2
4
  module Helpers
3
5
  # Helper for registering valid record types
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Gecko
2
4
  module Helpers
3
5
  # Provides serialization to records
@@ -28,6 +30,7 @@ module Gecko
28
30
  attribute_hash = {}
29
31
  attribute_set.each do |attribute|
30
32
  next unless writeable?(attribute)
33
+
31
34
  serialize_attribute(attribute_hash, attribute)
32
35
  end
33
36
 
@@ -46,6 +49,7 @@ module Gecko
46
49
  def writeable?(attribute)
47
50
  return if attribute.options[:readonly]
48
51
  return true unless attribute.options[:writeable_on]
52
+
49
53
  case attribute.options[:writeable_on]
50
54
  when :update
51
55
  persisted?
@@ -75,7 +79,7 @@ module Gecko
75
79
  # @return [String]
76
80
  #
77
81
  # @api private
78
- def _serialize(serialized)
82
+ def _serialize(serialized) # rubocop:disable Metrics/MethodLength
79
83
  if serialized.respond_to?(:serializable_hash)
80
84
  serialized.serializable_hash
81
85
  else