Class: Zensana::Zendesk::Attachment
- Inherits:
-
Object
- Object
- Zensana::Zendesk::Attachment
- Includes:
- Access
- Defined in:
- lib/zensana/models/zendesk/attachment.rb
Constant Summary collapse
- MAX_ATTACHMENT_SIZE =
2*10**6
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
Instance Method Summary collapse
-
#initialize ⇒ Attachment
constructor
A new instance of Attachment.
- #method_missing(name, *args, &block) ⇒ Object
- #too_big?(file) ⇒ Boolean
- #upload(filename) ⇒ Object
Methods included from Access
Constructor Details
#initialize ⇒ Attachment
Returns a new instance of Attachment.
10 11 12 |
# File 'lib/zensana/models/zendesk/attachment.rb', line 10 def initialize @attributes = {} end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
22 23 24 |
# File 'lib/zensana/models/zendesk/attachment.rb', line 22 def method_missing(name, *args, &block) attributes[name.to_s] || super end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
8 9 10 |
# File 'lib/zensana/models/zendesk/attachment.rb', line 8 def attributes @attributes end |
Instance Method Details
#too_big?(file) ⇒ Boolean
18 19 20 |
# File 'lib/zensana/models/zendesk/attachment.rb', line 18 def too_big?(file) File.size(file).to_f > MAX_ATTACHMENT_SIZE end |
#upload(filename) ⇒ Object
14 15 16 |
# File 'lib/zensana/models/zendesk/attachment.rb', line 14 def upload(filename) @attributes = upload_file(filename) end |