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 +4 -4
- data/app/models/concerns/records/base.rb +60 -0
- data/lib/bullet_train/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e043af38dcb40348528dd6b925433147b3e58f0fd64d969c7396feebce04091a
|
4
|
+
data.tar.gz: 4546e61efd71d6b92c270e02a50ff33e558d6007d4cc761c925192d77562459f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
data/lib/bullet_train/version.rb
CHANGED
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.
|
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
|