usman 0.3.5 → 0.3.6

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
  SHA1:
3
- metadata.gz: d22e2e3562f38ea5576027b67f5d2c82a9c36f39
4
- data.tar.gz: c858c47f7b5e81396f5f0dfc887283f9e54cee8d
3
+ metadata.gz: 66561139d596eb84bc2c00138dea1965ff65cec4
4
+ data.tar.gz: 2c3cf0d379d6daa1f7f5006ef5aa805778a4f23a
5
5
  SHA512:
6
- metadata.gz: 4f832c806ddedb96aed37fcb2e80e29d48277ff36bb5c77f297493f9bf2d2dc3205cd0a28ea0f201cc28650c9192d1c487e0ca614b7713755a0c37638e976b33
7
- data.tar.gz: abc03809d152fe4275f6741b2680fec4ea63087980d87473e6aca4c58a4547d9a110ed8e810c8644697f81db02beca0a89d9523766d310b1ca910e9d4357d8d5
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
@@ -1,3 +1,3 @@
1
1
  module Usman
2
- VERSION = '0.3.5'
2
+ VERSION = '0.3.6'
3
3
  end
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.5
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-26 00:00:00.000000000 Z
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