verse-ruby 0.1.4 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/verse.rb +1 -1
- data/lib/verse/auth.rb +3 -2
- data/lib/verse/auth/{confirmable/email.rb → email.rb} +1 -1
- data/lib/verse/auth/session.rb +7 -0
- data/lib/verse/auth/user.rb +9 -0
- data/lib/verse/controller.rb +6 -2
- data/lib/verse/controller/strong_params.rb +37 -0
- data/lib/verse/core.rb +2 -0
- data/lib/verse/core/business.rb +2 -0
- data/lib/verse/core/entity.rb +9 -1
- data/lib/verse/core/household.rb +5 -0
- data/lib/verse/core/person.rb +12 -0
- data/lib/verse/graph.rb +6 -0
- data/lib/verse/models.rb +1 -0
- data/lib/verse/relatable.rb +6 -0
- data/lib/verse/relatable/admin.rb +5 -0
- data/lib/verse/resource.rb +9 -2
- data/lib/verse/version.rb +1 -1
- metadata +11 -7
- data/lib/verse/auth/confirmable.rb +0 -8
- data/lib/verse/auth/core.rb +0 -9
- data/lib/verse/auth/core/session.rb +0 -3
- data/lib/verse/auth/core/user.rb +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3ca14379a3dab2da96706c1f8a1c4725cb39ff6c
|
4
|
+
data.tar.gz: 0d6edc678b1a64bc3295dc1a45992ed5ca0a19dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2589019d44b94ab2518a5b151f74fafea6587a6986a55be1ab3cae775858d67d9af818dbe2b54086d7b93ac4c21858f6b24a436788fa243dd4598e4411ccb8a7
|
7
|
+
data.tar.gz: 2cd730c2766a328704c4825fb7f31b7fbcd3ed506dfe20beece494146d8423b40ff38c4652bda1c071428f9cfaeec7c87d46373ce406f4e8fc01acbdb1391e70
|
data/lib/verse.rb
CHANGED
data/lib/verse/auth.rb
CHANGED
data/lib/verse/controller.rb
CHANGED
@@ -1,10 +1,14 @@
|
|
1
1
|
require 'active_support'
|
2
2
|
require 'jwt'
|
3
3
|
|
4
|
+
require 'verse/controller/strong_params'
|
5
|
+
|
4
6
|
module Verse
|
5
7
|
module Controller
|
6
8
|
extend ActiveSupport::Concern
|
7
9
|
|
10
|
+
include Verse::Controller::StrongParams
|
11
|
+
|
8
12
|
included do
|
9
13
|
before_action :set_user_token
|
10
14
|
helper_method :current_user
|
@@ -13,9 +17,9 @@ module Verse
|
|
13
17
|
def current_user
|
14
18
|
if Verse.user_token
|
15
19
|
data = JWT.decode(Verse.user_token, nil, false)[0]['data']
|
16
|
-
Verse::Auth::
|
20
|
+
Verse::Auth::User.new(
|
17
21
|
id: data['user_id'],
|
18
|
-
|
22
|
+
name: data['name'],
|
19
23
|
email: data['email'],
|
20
24
|
username: data['username']
|
21
25
|
)
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Verse
|
2
|
+
module Controller
|
3
|
+
module StrongParams
|
4
|
+
# Verse::Auth / Verse::Contactable
|
5
|
+
def email_attributes; end
|
6
|
+
|
7
|
+
# Verse::Auth
|
8
|
+
def session_attributes
|
9
|
+
params.require(:session).permit(:login, :password)
|
10
|
+
end
|
11
|
+
|
12
|
+
def user_attributes
|
13
|
+
params.require(:user).permit(:name, :username, :email, :password, :password_confirmation)
|
14
|
+
end
|
15
|
+
|
16
|
+
# Verse::Core
|
17
|
+
def entity_attributes
|
18
|
+
params.require(:entity).permit(:name, :slug, { admins_attributes: [:admin_id] })
|
19
|
+
end
|
20
|
+
|
21
|
+
def person_attributes
|
22
|
+
params.require(:person).permit(:name, :slug, { admins_attributes: [:admin_id] })
|
23
|
+
end
|
24
|
+
|
25
|
+
def business_attributes
|
26
|
+
params.require(:business).permit(:name, :slug, { admins_attributes: [:admin_id] })
|
27
|
+
end
|
28
|
+
|
29
|
+
def household_attributes
|
30
|
+
params.require(:household).permit(:name, { admins_attributes: [:admin_id] })
|
31
|
+
end
|
32
|
+
|
33
|
+
# Verse::Relatable
|
34
|
+
def admin_attributes; end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
data/lib/verse/core.rb
CHANGED
data/lib/verse/core/entity.rb
CHANGED
@@ -1,3 +1,11 @@
|
|
1
1
|
class Verse::Core::Entity < Verse::Resource
|
2
|
-
attributes :slug
|
2
|
+
attributes :name, :slug
|
3
|
+
|
4
|
+
has_many :admins, class_name: 'Verse::Auth::User'
|
5
|
+
has_many :owners, class_name: 'Verse::Core::Entity'
|
6
|
+
has_many :members, class_name: 'Verse::Core::Person'
|
7
|
+
|
8
|
+
def form_attributes
|
9
|
+
[:name, :slug, admins: [:admin_id]]
|
10
|
+
end
|
3
11
|
end
|
data/lib/verse/core/person.rb
CHANGED
@@ -1,2 +1,14 @@
|
|
1
1
|
class Verse::Core::Person < Verse::Core::Entity
|
2
|
+
has_many :entities, class_name: 'Verse::Core::Entity'
|
3
|
+
has_many :businesses, class_name: 'Verse::Core::Business'
|
4
|
+
has_many :households, class_name: 'Verse::Core::Household'
|
5
|
+
has_many :people, class_name: 'Verse::Core::Person'
|
6
|
+
|
7
|
+
# has_many :administrated_entities
|
8
|
+
|
9
|
+
# has_many :administrated_businesses
|
10
|
+
|
11
|
+
# has_many :administrated_people
|
12
|
+
|
13
|
+
# has_many :administrated_softwares
|
2
14
|
end
|
data/lib/verse/graph.rb
ADDED
data/lib/verse/models.rb
CHANGED
data/lib/verse/resource.rb
CHANGED
@@ -4,9 +4,16 @@ module Verse
|
|
4
4
|
|
5
5
|
include_root_in_json true
|
6
6
|
|
7
|
+
def specific
|
8
|
+
type = attributes[:type]
|
9
|
+
if type
|
10
|
+
"Verse::#{type}".constantize.new(attributes)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
7
14
|
# Demodulizes model_name e.g. for use in route helpers.
|
8
|
-
def self.model_name
|
9
|
-
ActiveModel::Name.new(self, nil, name.split('::').last)
|
15
|
+
def self.model_name
|
16
|
+
ActiveModel::Name.new(self, nil, name.split('::').last)
|
10
17
|
end
|
11
18
|
end
|
12
19
|
end
|
data/lib/verse/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: verse-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thom Bruce
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-12-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -188,19 +188,23 @@ files:
|
|
188
188
|
- lib/verse-ruby.rb
|
189
189
|
- lib/verse.rb
|
190
190
|
- lib/verse/auth.rb
|
191
|
-
- lib/verse/auth/
|
192
|
-
- lib/verse/auth/
|
193
|
-
- lib/verse/auth/
|
194
|
-
- lib/verse/auth/core/session.rb
|
195
|
-
- lib/verse/auth/core/user.rb
|
191
|
+
- lib/verse/auth/email.rb
|
192
|
+
- lib/verse/auth/session.rb
|
193
|
+
- lib/verse/auth/user.rb
|
196
194
|
- lib/verse/configuration.rb
|
197
195
|
- lib/verse/contactable.rb
|
198
196
|
- lib/verse/contactable/email.rb
|
199
197
|
- lib/verse/controller.rb
|
198
|
+
- lib/verse/controller/strong_params.rb
|
200
199
|
- lib/verse/core.rb
|
200
|
+
- lib/verse/core/business.rb
|
201
201
|
- lib/verse/core/entity.rb
|
202
|
+
- lib/verse/core/household.rb
|
202
203
|
- lib/verse/core/person.rb
|
204
|
+
- lib/verse/graph.rb
|
203
205
|
- lib/verse/models.rb
|
206
|
+
- lib/verse/relatable.rb
|
207
|
+
- lib/verse/relatable/admin.rb
|
204
208
|
- lib/verse/resource.rb
|
205
209
|
- lib/verse/version.rb
|
206
210
|
- verse-ruby.gemspec
|
data/lib/verse/auth/core.rb
DELETED
data/lib/verse/auth/core/user.rb
DELETED