Class: Auth::Image
- Inherits:
-
Object
- Object
- Auth::Image
- Includes:
- Concerns::OwnerConcern, Mongoid::Document
- Defined in:
- app/models/auth/image.rb
Instance Attribute Summary collapse
-
#public_id ⇒ Object
Returns the value of attribute public_id.
-
#signed_request ⇒ Object
Returns the value of attribute signed_request.
-
#timestamp ⇒ Object
Returns the value of attribute timestamp.
Class Method Summary collapse
-
.permitted_params ⇒ Object
CLASS METHODS.
Instance Method Summary collapse
-
#get_signed_request ⇒ Object
OTHER CUSTOM DEFS.
-
#parent_id_is_valid_bson ⇒ Object
CUSTOM VALIDATION DEFS.
- #public_id_equals_id ⇒ Object
-
#text_representation ⇒ Object
rendered in create, in the authenticated_controller.
Instance Attribute Details
#public_id ⇒ Object
Returns the value of attribute public_id.
37 38 39 |
# File 'app/models/auth/image.rb', line 37 def public_id @public_id end |
#signed_request ⇒ Object
Returns the value of attribute signed_request.
35 36 37 |
# File 'app/models/auth/image.rb', line 35 def signed_request @signed_request end |
#timestamp ⇒ Object
Returns the value of attribute timestamp.
36 37 38 |
# File 'app/models/auth/image.rb', line 36 def @timestamp end |
Class Method Details
.permitted_params ⇒ Object
CLASS METHODS
the parent id is the id of the object in which the image is uploaded. it need not exist. but has to be a valid bson object id.
18 19 20 |
# File 'app/models/auth/image.rb', line 18 def self.permitted_params [{:image => [:_id,:parent_id,:parent_class,:active,:timestamp,:public_id]},:id] end |
Instance Method Details
#get_signed_request ⇒ Object
OTHER CUSTOM DEFS.
92 93 94 95 96 |
# File 'app/models/auth/image.rb', line 92 def get_signed_request Cloudinary::Utils.sign_request({:public_id => self.id.to_s,:timestamp=> self., :callback => "http://widget.cloudinary.com/cloudinary_cors.html"}, :options=>{:api_key=>Cloudinary.config.api_key, :api_secret=>Cloudinary.config.api_secret}) end |
#parent_id_is_valid_bson ⇒ Object
CUSTOM VALIDATION DEFS.
73 74 75 76 77 78 79 |
# File 'app/models/auth/image.rb', line 73 def parent_id_is_valid_bson begin BSON::ObjectId.from_string(self.parent_id) rescue self.errors.add(:parent_id, "the parent id is not valid") end end |
#public_id_equals_id ⇒ Object
81 82 83 |
# File 'app/models/auth/image.rb', line 81 def public_id_equals_id self.errors.add(:public_id, "the public id and object id are not equal") if (self.id.to_s != self.public_id) end |
#text_representation ⇒ Object
rendered in create, in the authenticated_controller.
99 100 101 |
# File 'app/models/auth/image.rb', line 99 def text_representation self.signed_request[:signature].to_s end |