ar_doc_store 2.0.1 → 2.0.2

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: caad9dbeece3c6c946760fe2acf43521b082b0ef7811640149d08abe1cac0642
4
- data.tar.gz: 0b362a0cfd84cb661b0fcf93e548fd2de0701657fedbc4ae69bbd54c8ed8a376
3
+ metadata.gz: cb15be10e81091e7b3097de1f850c17c35441c48a474aa2b4429e816d8090c07
4
+ data.tar.gz: 254d183d092b733d0eaab89792266940221c5b6aa4e06c930f7544edf63d8e3d
5
5
  SHA512:
6
- metadata.gz: ae4881ded95f29b08516c6dbb7f3cfe04505b79675b2283ef7e0cad6fb00a322a6e32d204c71a3f6463df980d41ad571c92cb979ca964306773abc0b4b871932
7
- data.tar.gz: c37de01ce4e5e8075f0eee586cc98c9f2919ffb0f46d665c1f32c4783eb1863a1a6889cdcfd5247173b32d617a3b0626aacee0dd37726a58dc3fe523b9eaf39f
6
+ metadata.gz: a3f6fa036da43c10a0b1a0f9b260f31aa344b537c03dea053d52389abc257ef267ce2bb7eea9ac677cc042597d8c0f55612e5e8725b07a03ed1f124c8cf3c7ee
7
+ data.tar.gz: faa156db5a2cddc18756eba7edf9f011e8476fabe22651017dda706201be812a33cd5e394aa72a20f361dcc010651e1b94a412e4a3bce4429e7bd07b5ce7170e
@@ -10,7 +10,7 @@ module ArDocStore
10
10
 
11
11
  module InstanceMethods
12
12
  def assign_json_data
13
- json_data = self[json_column]
13
+ json_data = respond_to?(json_column) && self[json_column]
14
14
  return if json_data.blank?
15
15
  json_attributes.keys.each do |key|
16
16
  next unless json_data.key?(key)
@@ -24,8 +24,8 @@ module ArDocStore
24
24
  def add_ransacker(key, predicate = nil)
25
25
  return unless respond_to?(:ransacker)
26
26
  ransacker key do |parent|
27
- sql = "(#{parent.table[:data]}->>'#{key}')"
28
- if predicate
27
+ sql = "(#{parent.table[json_column].name}->>'#{key}')"
28
+ if predicate.present?
29
29
  sql = "#{sql}::#{predicate}"
30
30
  end
31
31
  Arel.sql(sql)
@@ -1,3 +1,3 @@
1
1
  module ArDocStore
2
- VERSION = "2.0.1"
2
+ VERSION = "2.0.2"
3
3
  end
@@ -30,4 +30,9 @@ class StringAttributeTest < MiniTest::Test
30
30
  assert_equal 'Test', Building.find(b.id).name
31
31
  end
32
32
 
33
+ def test_html_attribute_name
34
+ t = Building.create html: 'foobar', name: 'Test', stories: 5
35
+ assert_equal t.html, 'foobar'
36
+ end
37
+
33
38
  end
@@ -9,7 +9,7 @@ ActiveRecord::Base.establish_connection(adapter: 'postgresql', database: 'ar_doc
9
9
 
10
10
  require 'active_record/migration'
11
11
 
12
- ActiveRecord::Migration.execute "DROP TABLE IF EXISTS purchase_orders"
12
+ ActiveRecord::Migration[4.2].execute "DROP TABLE IF EXISTS purchase_orders"
13
13
  ActiveRecord::Migration.execute "DROP TABLE IF EXISTS buildings"
14
14
  ActiveRecord::Migration.create_table :buildings do |t|
15
15
  t.jsonb :data
@@ -33,7 +33,7 @@ end
33
33
 
34
34
  class Door
35
35
  include ArDocStore::EmbeddableModel
36
- enumerates :door_type, multiple: true, values: %w{single double french sliding push pull}
36
+ json_attribute :door_type, as: :enumeration, multiple: true, values: %w{single double french sliding push pull}
37
37
  json_attribute :open_handle, as: :enumeration, multiple: true, values: %w{push pull plate knob handle}
38
38
  json_attribute :close_handle, as: :enumeration, multiple: true, values: %w{push pull plate knob handle}
39
39
  json_attribute :clear_distance, as: :integer
@@ -69,6 +69,7 @@ class Building < ActiveRecord::Base
69
69
  json_attribute :inspected_at, as: :datetime
70
70
  json_attribute :finished_on, as: :date
71
71
  json_attribute :cost, as: :decimal
72
+ json_attribute :html
72
73
  embeds_one :entrance
73
74
  embeds_one :main_entrance, class_name: 'Entrance'
74
75
  embeds_many :restrooms
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ar_doc_store
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Furber
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-09-28 00:00:00.000000000 Z
11
+ date: 2018-11-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord