blueprinter_schema 0.4.2 → 0.5.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
  SHA256:
3
- metadata.gz: 0a5c36ae7940be0f29d7fa96352756ac959c03dfb61d968d4080d1368a7eb29c
4
- data.tar.gz: cf498e454ca5349f419ac3e2db8d1efe9ee686ae09d34570be8523757e983e42
3
+ metadata.gz: 03c37dc53060c99e65e98088279e4e635bcedd8b495c9c9d4b31c624c7b56488
4
+ data.tar.gz: 5c82b98494016b536ed9e9f360353834c5daaf28e692a4a16fa8c5e466924733
5
5
  SHA512:
6
- metadata.gz: d5eaf5134861ca54d30c5e1380ba7e0afa15db73c692bc84591903a04b2d3a2190628e8221fd58506c0c328cf2da149f4df7813faeec29b92d2333910487cc93
7
- data.tar.gz: 6259270843fd90b83c08d797d1cd81799072e5b5d0c4e2295353c9b963e6e06b8729dde7f45e41121d4416a709f11e8a1aa7ed0d2a977180de98424b4d493d3b
6
+ metadata.gz: a118085debb64d40d46aae65e8c88ddc69c0e55e49949e580966618ea14b7573a05c02a0df47aa8cac4c09bb2872b50c002e7828b275954a045728fa56115d6e
7
+ data.tar.gz: b05ee47b64997f7dbc0d16b0f8bf440e76e61d810d82b79ff3295d46f07c051b8048076db67983fd8df940e78f69b30e5504a2e646590f429993dc97ef1be5dd
data/README.md CHANGED
@@ -91,7 +91,8 @@ BlueprinterSchema.generate(
91
91
  model,
92
92
  {
93
93
  include_conditional_fields: true, # Whether or not to include conditional fields from the serializer
94
- fallback_type: {} # Type when no DB column is found or type is unknown. E.g. { 'type' => 'object' }
94
+ fallback_type: {}, # Type when no DB column is found or type is unknown. E.g. { 'type' => 'object' }
95
+ view: :default # The Blueprint view to use
95
96
  }
96
97
  )
97
98
  ```
@@ -2,7 +2,7 @@
2
2
 
3
3
  module BlueprinterSchema
4
4
  class Generator
5
- def initialize(serializer, model, options = { include_conditional_fields: true, fallback_type: {} })
5
+ def initialize(serializer, model, options)
6
6
  @serializer = serializer
7
7
  @model = model
8
8
  @options = options
@@ -21,11 +21,11 @@ module BlueprinterSchema
21
21
  private
22
22
 
23
23
  def fields
24
- @fields ||= @serializer.reflections[:default].fields
24
+ @fields ||= @serializer.reflections[@options[:view]].fields
25
25
  end
26
26
 
27
27
  def associations
28
- @associations ||= @serializer.reflections[:default].associations
28
+ @associations ||= @serializer.reflections[@options[:view]].associations
29
29
  end
30
30
 
31
31
  def build_properties
@@ -45,7 +45,8 @@ module BlueprinterSchema
45
45
  end
46
46
 
47
47
  def skip_field?(field)
48
- !@options[:include_conditional_fields] && (field.options[:if] || field.options[:unless])
48
+ !@options[:include_conditional_fields] &&
49
+ (field.options[:if] || field.options[:unless] || field.options[:exclude_if_nil])
49
50
  end
50
51
 
51
52
  def build_required_fields
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module BlueprinterSchema
4
- VERSION = '0.4.2'
4
+ VERSION = '0.5.0'
5
5
  end
@@ -4,7 +4,7 @@ require_relative 'blueprinter_schema/version'
4
4
  require_relative 'blueprinter_schema/generator'
5
5
 
6
6
  module BlueprinterSchema
7
- def self.generate(serializer, model, options = { include_conditional_fields: true, fallback_type: {} })
7
+ def self.generate(serializer, model, options = { include_conditional_fields: true, fallback_type: {}, view: :default })
8
8
  Generator.new(serializer, model, options).generate
9
9
  end
10
10
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blueprinter_schema
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - thisismydesign