teamable 0.1.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1860e39d3cd85c51f07d0a6eafdb2b8fb54fd6857b31b828803ebf96ed83779c
4
- data.tar.gz: 4aa1de393a617deaaea7508d7236b60eb6617091766fc654973b4be6b8365462
3
+ metadata.gz: aef4a40776f50d3acd1148b325ed1be22771bc4d0a0b887dc19922f6919872a4
4
+ data.tar.gz: 3835d42ce487b9987189fc89d9a50a61d37d6045f7a72002773943052ae0e082
5
5
  SHA512:
6
- metadata.gz: 1ee01575799e26c74d465da1c28fe90c0e5598c91b24732f17419e2332c27b8f5f12834affedbbe8c505b65e8b97d7ba8690d8454462638e52702bbe4558b629
7
- data.tar.gz: fb3521f7e93c51498120d6c17d3a58295dee54d66dd488d2d804023d6822043c7a6083c4ff4f98e6b44eee119e597d54b27fdf0a77da7334fe12d10c88925322
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.1.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.1.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