schnecke 0.3.0 → 0.4.1

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: bdf704d77a580357657db281c7fd5021045fcd5c2b7cca9f32f6f468cf33d895
4
- data.tar.gz: 995fc538958ecf0ae7b1ce67cb81498e4223b3538782cc036a9763eefa1c0e4f
3
+ metadata.gz: cf00b01bf00cde122ae9803da93d3cf296cd554817230a9d40bfdedb766f6f95
4
+ data.tar.gz: f76bc3bfd995433f6416195896144b866d79e3e55a570ee4040af02104d7d753
5
5
  SHA512:
6
- metadata.gz: fd373216be05945333cc1ddd6850892151549db1e887cc64ce462ae4f98ee4e86b698e34d591b71f6fd667f5cb65ae8a3634a175a9186f88ee3c97035fcc06af
7
- data.tar.gz: d62fc13e0f3151f338314d79e7664267812b2de7f5a70ef6e1ba5fbb24ae550a569bf7266858906ee8f7502387aa76bf7687b9f8cf3c73a6a65a0a584213604f
6
+ metadata.gz: 4b23142e4aca5135edf71a409b07141ea9f99294dcdb6a21f6a57458c060bb9992ebced0a9831153a1ec27a61e4ea53d75803575e56b57838a515bfb6c68e311
7
+ data.tar.gz: aa1c74cec0b37a5a8a0be92928a31c0f9358e14db9de1c8f985f41ec03e845f3ada766290249cd17c52e177dcec0f719fac78ade88afbec5af7f35a2b8e0be47
data/.circleci/config.yml CHANGED
@@ -13,7 +13,7 @@ commands:
13
13
  - run:
14
14
  name: Set up bundler
15
15
  command: |
16
- gem install bundler:2.3.22
16
+ gem install bundler:2.3.26
17
17
  - run:
18
18
  name: Bundle Install
19
19
  command: |
@@ -46,7 +46,7 @@ jobs:
46
46
  resource_class: small
47
47
 
48
48
  docker:
49
- - image: cimg/ruby:3.1.2
49
+ - image: cimg/ruby:3.1.3
50
50
 
51
51
  steps:
52
52
  # --------- SETUP ---------
@@ -73,7 +73,7 @@ jobs:
73
73
  resource_class: small
74
74
 
75
75
  docker:
76
- - image: cimg/ruby:3.1.2
76
+ - image: cimg/ruby:3.1.3
77
77
 
78
78
  steps:
79
79
  # --------- SETUP ---------
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- ruby-3.1.2
1
+ ruby-3.1.3
data/.travis.yml CHANGED
@@ -3,5 +3,5 @@ sudo: false
3
3
  language: ruby
4
4
  cache: bundler
5
5
  rvm:
6
- - 2.6.3
7
- before_install: gem install bundler -v 1.17.3
6
+ - 3.1.3
7
+ before_install: gem install bundler -v 2.3.26
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- schnecke (0.3.0)
4
+ schnecke (0.4.1)
5
5
  activerecord (> 4.2.0)
6
6
  activesupport (> 4.2.0)
7
7
 
@@ -70,6 +70,7 @@ GEM
70
70
 
71
71
  PLATFORMS
72
72
  x86_64-darwin-21
73
+ x86_64-darwin-22
73
74
  x86_64-linux
74
75
 
75
76
  DEPENDENCIES
@@ -87,4 +88,4 @@ DEPENDENCIES
87
88
  sqlite3
88
89
 
89
90
  BUNDLED WITH
90
- 2.3.22
91
+ 2.3.26
data/README.md CHANGED
@@ -59,6 +59,44 @@ obj.assign_slug
59
59
  obj.reassign_slug
60
60
  ```
61
61
 
62
+ ### Using a method to define a slug source
63
+
64
+ There are times when the source of the slug needs to be set based on some other values (e.g. a parent object, random number, etc). In this case, simply define a method that is to be used to set the soure of the slug. This method can be public, protected, or private.
65
+
66
+ ```ruby
67
+ class SomeObject
68
+ include Schnecke
69
+ slug :parent_slug
70
+
71
+ belongs_to :parent_object
72
+
73
+ protected
74
+
75
+ def parent_slug
76
+ parent_object.slug
77
+ end
78
+ end
79
+ ```
80
+
81
+ Just like if one is using a plain old attributes, one can mix and match methods and attributes if the slug is to be derived from multiple sources
82
+
83
+ ```ruby
84
+ class SomeObject
85
+ include Schnecke
86
+ slug [:name, :parent_slug]
87
+
88
+ belongs_to :parent_object
89
+
90
+ protected
91
+
92
+ def parent_slug
93
+ parent_object.slug
94
+ end
95
+ end
96
+ ```
97
+
98
+ And this will take the `:name` attribute and the result from `parent_slug` and create a slug from the two things combined.
99
+
62
100
  ### Slug column
63
101
 
64
102
  By default it is assumed that the generated slug will be assigned to the `slug` attribute of the model. If one needs to place the slug in a different columm, this can be done by defining the `column` attribute:
@@ -189,7 +189,7 @@ module Schnecke
189
189
  def validate_slug_source
190
190
  source = arrayify(schnecke_config[:slug_source])
191
191
  source.each do |attr|
192
- unless respond_to?(attr)
192
+ unless respond_to?(attr, true)
193
193
  raise ArgumentError,
194
194
  "Source '#{attr}' does not exist."
195
195
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Schnecke
4
- VERSION = '0.3.0'
4
+ VERSION = '0.4.1'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: schnecke
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Patrick R. Schmid
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-10-03 00:00:00.000000000 Z
11
+ date: 2022-12-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -239,7 +239,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
239
239
  - !ruby/object:Gem::Version
240
240
  version: '0'
241
241
  requirements: []
242
- rubygems_version: 3.3.7
242
+ rubygems_version: 3.3.26
243
243
  signing_key:
244
244
  specification_version: 4
245
245
  summary: Simple and straightforward way to add slugs to ActiveRecod models.