recourse 5.6.2 → 5.6.3
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/lib/recourse/helpers/resources.rb +20 -1
- data/lib/recourse/icons.rb +5 -2
- data/lib/recourse/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 83d3a5ce095d609bf7da53c08839eab3bc4924c6e6150f9675d79725c4c9f53f
|
|
4
|
+
data.tar.gz: d2325213f4e461394adb107d3a3834f6ef668159ce6e90e7fa77aa09d09a8389
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 54d4c8b8075fc497c45caf991fe7f8e5ea04cacb30bf619a12682e137cf962072140b1ff69eaff9ad881658adb018a440bc344fd3bfb3859ec776bdd077ae87b
|
|
7
|
+
data.tar.gz: 9d8a3e17c0cdb3e05f57381beda1c68b31b5b6924d7104717622c29d5658f6faa198ab33d1c576a81ea8e7adf4ccdee3b9be885c248421302229381536dc7445
|
|
@@ -3,6 +3,10 @@ module Recourse
|
|
|
3
3
|
# What the page is about and what it is called: the model behind it, the record
|
|
4
4
|
# on it, and the words both are read out under.
|
|
5
5
|
module Resources
|
|
6
|
+
# Where Ruby's own `to_s` lives: a record whose model never wrote one prints the
|
|
7
|
+
# object's address, which is no name for a page.
|
|
8
|
+
DEFAULT_PRINTERS = [Kernel, Object].freeze
|
|
9
|
+
|
|
6
10
|
# Human, plural name of the resource on the page, e.g. `Contacts`. A page of
|
|
7
11
|
# attachments is named after what the record calls them rather than after Active
|
|
8
12
|
# Storage's own word for the row: `Photos`, never `Blobs`. `known_title`, since a
|
|
@@ -42,11 +46,26 @@ module Recourse
|
|
|
42
46
|
# What the record on the page is called, by whatever its model labels it with —
|
|
43
47
|
# and nothing where there is no record to name.
|
|
44
48
|
def resource_record_label
|
|
45
|
-
resource_record
|
|
49
|
+
return unless resource_record
|
|
50
|
+
|
|
51
|
+
labelled_record.presence || printed_record
|
|
46
52
|
end
|
|
47
53
|
|
|
48
54
|
private
|
|
49
55
|
|
|
56
|
+
# The column the model labels itself by, which most models keep.
|
|
57
|
+
def labelled_record
|
|
58
|
+
resource_record.attributes[resource_model.recourse_label.to_s]
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
# And what the record prints itself as, for the models that keep no such column:
|
|
62
|
+
# a chat is called by the first thing asked in it, which no column holds. Only
|
|
63
|
+
# where the model wrote a `to_s` of its own — the one Ruby supplies prints the
|
|
64
|
+
# object's address, which names nothing and is worse than an unnamed crumb.
|
|
65
|
+
def printed_record
|
|
66
|
+
resource_record.to_s unless DEFAULT_PRINTERS.include? resource_record.method(:to_s).owner
|
|
67
|
+
end
|
|
68
|
+
|
|
50
69
|
# Resolved by the controller, which is the one that knows whether the name is a
|
|
51
70
|
# model of this app's, something a record has attached, or a model a host named.
|
|
52
71
|
def resource_model
|
data/lib/recourse/icons.rb
CHANGED
|
@@ -3,11 +3,14 @@
|
|
|
3
3
|
module Recourse
|
|
4
4
|
# What a resource is drawn with, by the name of the class a route resolves to, and
|
|
5
5
|
# nil where there is no such class -- a bare action is drawn under a word this app
|
|
6
|
-
# has no class for, and an icon is not worth raising over.
|
|
6
|
+
# has no class for, and an icon is not worth raising over. A word that does resolve
|
|
7
|
+
# is not a drawn model either where what it found never heard of `recourse_icon`:
|
|
8
|
+
# `Message` may be a host's own class for gathering rows rather than a table of them,
|
|
9
|
+
# and asking it would raise rather than draw nothing.
|
|
7
10
|
def self.known_icon(name)
|
|
8
11
|
model = name.to_s.split('/').last.classify.safe_constantize
|
|
9
12
|
|
|
10
|
-
known_model_icon model if model
|
|
13
|
+
known_model_icon model if model.respond_to? :recourse_icon
|
|
11
14
|
end
|
|
12
15
|
|
|
13
16
|
# And for a model in hand. Nil rather than Unicon's circle where it has never heard
|
data/lib/recourse/version.rb
CHANGED