teamable 0.2.0 → 0.2.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: 9833a5564d208a343c0c4f0cae5786c4ebacd0da3cd40e26caef9e54ce69919c
4
- data.tar.gz: 1b967b399a9f8199c6eb347726aac9ac1c6ba0831060e4286723af32351c3450
3
+ metadata.gz: aef4a40776f50d3acd1148b325ed1be22771bc4d0a0b887dc19922f6919872a4
4
+ data.tar.gz: 3835d42ce487b9987189fc89d9a50a61d37d6045f7a72002773943052ae0e082
5
5
  SHA512:
6
- metadata.gz: 3e59f99011ca6c98b43c067b051398c9ba03e64814982625f98483d6608da725b49edb9f3e213255026da33a7dfa16216a0502614c2c41c938fee31721bf75a2
7
- data.tar.gz: 024ae176f2fc34b02a5897191b39600bdc45fe2aca3529a971edf5dea194124ecf47805df42241e197578bf70e02d745fa3e66b95a283828ee0843847990e303
6
+ metadata.gz: 9c0dd8dd693dc1ad3dd7b27a6376889e3c5e669cf35c54e64002db51862a0f3f179c023c67f09654076073605d24b9ba9a4729bb592759c5dc929b038aae80c2
7
+ data.tar.gz: 2ba7c15ec33d622960056bf4976c427b48b66f0ffa21c6330139cf9fc37e43e608b52430719679434cf1dc2a049725ae237ba44e47a0d1044550bc805885dcd4
data/README.md CHANGED
@@ -34,7 +34,7 @@ When building your customized account switcher, redirect your user to `switch_ac
34
34
 
35
35
  ```ruby
36
36
  current_user.accounts.each do |account|
37
- button_to account.name, switch_account_path(account), method: :patch
37
+ button_to account.name, switch_account_path(account), method: :patch
38
38
  end
39
39
  ```
40
40
 
@@ -44,7 +44,7 @@ Installation
44
44
  Add the following line to Gemfile:
45
45
 
46
46
  ```ruby
47
- gem "teamable", github: "kiqr/teamable" # Use Github repo to use alpha release.
47
+ gem "teamable", "~> 0.2.0"
48
48
  ```
49
49
 
50
50
  and run `bundle install` from your terminal to install it.
@@ -122,7 +122,7 @@ should) specify a dependency on this gem using the [Pessimistic Version
122
122
  Constraint](http://guides.rubygems.org/patterns/#pessimistic-version-constraint) with two digits of precision. For example:
123
123
 
124
124
  ```ruby
125
- gem "teamable", "~> 1.0"
125
+ gem "teamable", "~> 0.2.0"
126
126
  ```
127
127
 
128
128
  License
@@ -37,7 +37,7 @@ module Teamable
37
37
  end
38
38
 
39
39
  def add_route
40
- route 'teamable "account"'
40
+ route 'teamable "team"'
41
41
  end
42
42
 
43
43
  private
@@ -43,9 +43,7 @@ module Teamable
43
43
  # Load current account from Account model and store it
44
44
  # in the Teamable::Current singleton.
45
45
  def load_current_account
46
- return unless user_signed_in?
47
-
48
- Teamable::Current.account ||= account_from_params || current_user.personal_account || nil
46
+ Teamable::Current.account ||= account_from_params || account_from_personal_account || nil
49
47
  end
50
48
 
51
49
  # Try to load current account using session[:teamable_account_id]
@@ -55,12 +53,11 @@ module Teamable
55
53
  current_user.accounts.find_puid(params[:account_id])
56
54
  end
57
55
 
58
- # Finds last joined account if the user have any associated accounts.
59
- def fallback_account
60
- memberships = current_user.members
61
- return nil if memberships.empty?
56
+ # Try to load current account using current_user.personal_account
57
+ def account_from_personal_account
58
+ return unless defined?(current_user) && !current_user.nil?
62
59
 
63
- memberships.last.account # Return last joined account.
60
+ current_user&.personal_account
64
61
  end
65
62
 
66
63
  # Check if the current controller is a TeamableController
@@ -1,3 +1,3 @@
1
1
  module Teamable
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: teamable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rasmus Kjellberg
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2024-03-10 00:00:00.000000000 Z
12
+ date: 2024-03-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: dry-configurable