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.
40 41 42 |
# File 'app/models/auth/image.rb', line 40 def public_id @public_id end |
#signed_request ⇒ Object
Returns the value of attribute signed_request.
38 39 40 |
# File 'app/models/auth/image.rb', line 38 def signed_request @signed_request end |
#timestamp ⇒ Object
Returns the value of attribute timestamp.
39 40 41 |
# File 'app/models/auth/image.rb', line 39 def 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.
21 22 23 |
# File 'app/models/auth/image.rb', line 21 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.
95 96 97 98 99 |
# File 'app/models/auth/image.rb', line 95 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.
76 77 78 79 80 81 82 |
# File 'app/models/auth/image.rb', line 76 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
84 85 86 |
# File 'app/models/auth/image.rb', line 84 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.
102 103 104 |
# File 'app/models/auth/image.rb', line 102 def text_representation self.signed_request[:signature].to_s end |