bullet_train 1.0.8 → 1.0.9

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: 7c456427f05a6de4ee6550f5b6e0b0631e196774e03375bbf59c5d35a9420755
4
- data.tar.gz: c472262b19400507b36cdbad3699136464d2cdec48e1b24c5a5c011a8f5b337c
3
+ metadata.gz: e043af38dcb40348528dd6b925433147b3e58f0fd64d969c7396feebce04091a
4
+ data.tar.gz: 4546e61efd71d6b92c270e02a50ff33e558d6007d4cc761c925192d77562459f
5
5
  SHA512:
6
- metadata.gz: 8197df1a2ad180566d7a998dc0ba290c1c67a660c4c755f0aa6ef11ec8e2f60c97481a102d590b5a4b623e1257536b93c2007f72f0a3143829f5ab5f928fe4e9
7
- data.tar.gz: 72ecd65e81e5d69605381baa864370cb003abd6ff7fff44708eefa351f33b7108b9fa9547e9ac1c88ca324a1aef702879dde9a5cd4c83a10f55fe896d36ff75d
6
+ metadata.gz: 4f448f5cacf14583c92761252adff72ee3c7b8474b291e1ccb3f4b7874acf341a329fc5ee96be8d948d7394739abd5508fa78a813b0d922daae5b82d791eafa0
7
+ data.tar.gz: b0865e4751fd3819475fea1bab30e30e503f21ad75d884e69db241af605a6178519ea3bb6b4c617a84b75c8f2888eb94ba377ee762c6218a1a21830617323c5e
@@ -0,0 +1,60 @@
1
+ module Records::Base
2
+ extend ActiveSupport::Concern
3
+
4
+ included do
5
+ if defined?(Webhooks::Outgoing::IssuingModel)
6
+ include Webhooks::Outgoing::IssuingModel
7
+ end
8
+
9
+ if defined?(ObfuscatesId)
10
+ include ObfuscatesId
11
+ end
12
+
13
+ if defined?(QuestionMethodsFromScopes)
14
+ include QuestionMethodsFromScopes
15
+ end
16
+
17
+ include CableReady::Updatable
18
+ enable_updates
19
+
20
+ extend ActiveHash::Associations::ActiveRecordExtensions
21
+
22
+ # 🏚 i'd like to deprecate these. they're not descriptive enough.
23
+ scope :newest, -> { order("created_at DESC") }
24
+ scope :oldest, -> { order("created_at ASC") }
25
+
26
+ scope :newest_created, -> { order("created_at DESC") }
27
+ scope :oldest_created, -> { order("created_at ASC") }
28
+ scope :newest_updated, -> { order("updated_at DESC") }
29
+ scope :oldest_updated, -> { order("updated_at ASC") }
30
+
31
+ # Microscope adds useful scopes targeting ActiveRecord `boolean`, `date` and `datetime` attributes.
32
+ # https://github.com/mirego/microscope
33
+ acts_as_microscope
34
+ end
35
+
36
+ class_methods do
37
+ # by default we represent methods by their first string attribute.
38
+ def label_attribute
39
+ columns_hash.values.find { |column| column.sql_type_metadata.type == :string }&.name
40
+ end
41
+ end
42
+
43
+ # this is a template method you can override in activerecord models if we shouldn't just use their first string to
44
+ # identify them.
45
+ def label_string
46
+ if (label_attribute = self.class.label_attribute)
47
+ send("#{label_attribute}_was")
48
+ else
49
+ self.class.name.underscore.split("/").last.titleize
50
+ end
51
+ end
52
+
53
+ def parent_collection
54
+ # TODO Try to suggest what the entire method definition should actually be
55
+ # using parent_key below to do so.
56
+ model_name = self.class
57
+ # parent_key = model_name.reflect_on_all_associations(:belongs_to).first.name
58
+ raise "You're trying to use a feature that requires #{model_name} to have a `collection` method defined that returns the Active Record association that this model belongs to within its parent object."
59
+ end
60
+ end
@@ -1,3 +1,3 @@
1
1
  module BulletTrain
2
- VERSION = "1.0.8"
2
+ VERSION = "1.0.9"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bullet_train
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.8
4
+ version: 1.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Culver
@@ -75,6 +75,7 @@ files:
75
75
  - app/mailers/user_mailer.rb
76
76
  - app/models/concerns/invitations/base.rb
77
77
  - app/models/concerns/memberships/base.rb
78
+ - app/models/concerns/records/base.rb
78
79
  - app/models/concerns/teams/base.rb
79
80
  - app/models/concerns/users/base.rb
80
81
  - app/models/invitation.rb