usman 0.3.5 → 0.3.6
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/app/models/user.rb +4 -0
- data/app/serializers/owner_serializer.rb +20 -0
- data/app/serializers/registration_serializer.rb +29 -0
- data/lib/usman/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 66561139d596eb84bc2c00138dea1965ff65cec4
|
4
|
+
data.tar.gz: 2c3cf0d379d6daa1f7f5006ef5aa805778a4f23a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 47860d3bdb74aa8a34e333d6eff9a00932e2aa19ea5e441cd093cb2ca6938e5de654fe71b81873f092f4350116c02ea0d4c196d8c0270666acad0a148049fc1e
|
7
|
+
data.tar.gz: '09a34bbc72197d03d4c9a246698b7e82f8a7ffc06d0287899afe9155cd1490e2b3821af4abefe7193845b2ba90035fcb21652c9db3ecf24610ca1102b6f7d874'
|
data/app/models/user.rb
CHANGED
@@ -52,6 +52,10 @@ class User < Usman::ApplicationRecord
|
|
52
52
|
# Callbacks
|
53
53
|
before_validation :generate_auth_token
|
54
54
|
|
55
|
+
# Delegates
|
56
|
+
delegate :mobile_number, :to => :registration, :prefix => true, :allow_nil => true
|
57
|
+
delegate :dialing_prefix, :to => :registration, :prefix => true, :allow_nil => true
|
58
|
+
|
55
59
|
# Associations
|
56
60
|
has_one :profile_picture, :as => :imageable, :dependent => :destroy, :class_name => "Image::ProfilePicture"
|
57
61
|
has_many :permissions
|
@@ -0,0 +1,20 @@
|
|
1
|
+
class OwnerSerializer < ActiveModel::Serializer
|
2
|
+
include NullAttributeReplacer
|
3
|
+
attributes :id, :name, :email
|
4
|
+
|
5
|
+
has_one :registration, class_name: "Registration", serializer: RegistrationSerializer do
|
6
|
+
if object.registration
|
7
|
+
object.registration
|
8
|
+
else
|
9
|
+
object.build_registration
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
has_one :profile_picture, class_name: "Image::ProfilePicture", serializer: ProfilePictureSerializer do
|
14
|
+
if object.profile_picture
|
15
|
+
object.profile_picture
|
16
|
+
else
|
17
|
+
object.build_profile_picture
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
class RegistrationSerializer < ActiveModel::Serializer
|
2
|
+
include NullAttributeReplacer
|
3
|
+
|
4
|
+
attributes :id, :dialing_prefix, :mobile_number, :status
|
5
|
+
|
6
|
+
has_one :user, class_name: "User", serializer: ProfileSerializer do
|
7
|
+
if object.user
|
8
|
+
object.user
|
9
|
+
else
|
10
|
+
object.build_user
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
has_one :country, class_name: "Country", serializer: CountryPreviewSerializer do
|
15
|
+
if object.country
|
16
|
+
object.country
|
17
|
+
else
|
18
|
+
object.build_country
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
has_one :city, class_name: "City", serializer: CityPreviewSerializer do
|
23
|
+
if object.city
|
24
|
+
object.city
|
25
|
+
else
|
26
|
+
object.build_city
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/lib/usman/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: usman
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kpvarma
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-09-
|
11
|
+
date: 2017-09-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -404,8 +404,10 @@ files:
|
|
404
404
|
- app/models/role.rb
|
405
405
|
- app/models/user.rb
|
406
406
|
- app/models/usman/application_record.rb
|
407
|
+
- app/serializers/owner_serializer.rb
|
407
408
|
- app/serializers/profile_picture_serializer.rb
|
408
409
|
- app/serializers/profile_serializer.rb
|
410
|
+
- app/serializers/registration_serializer.rb
|
409
411
|
- app/services/usman/authentication_service.rb
|
410
412
|
- app/services/usman/mobile_registration_service.rb
|
411
413
|
- app/uploaders/feature_image_uploader.rb
|