Class: Pdf4me::Base
- Inherits:
-
Object
- Object
- Pdf4me::Base
- Extended by:
- Serializer
- Includes:
- ActiveModel::Validations, Assigner
- Defined in:
- lib/pdf4me/models/base.rb
Direct Known Subclasses
ConvertToPdfAction, ConvertToPdfRes, DocLog, DocMetadata, Document, Notification, OptimizeAction, OptimizeRes, Page
Instance Method Summary collapse
- #attributes ⇒ Object
- #defaults ⇒ Object
-
#initialize(attrs = {}) ⇒ Base
constructor
A new instance of Base.
Methods included from Serializer
_deserialize, from_hash, from_response
Methods included from Assigner
Constructor Details
#initialize(attrs = {}) ⇒ Base
Returns a new instance of Base.
7 8 9 10 |
# File 'lib/pdf4me/models/base.rb', line 7 def initialize(attrs = {}) merged_attrs = defaults.merge(attrs) assign_attributes(merged_attrs) end |
Instance Method Details
#attributes ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/pdf4me/models/base.rb', line 16 def attributes attrs = self.class::ATTRIBUTES.stringify_keys.keys attrs.each_with_object({}) do |attribute, memo| value = send(attribute) if value.present? memo[attribute.camelize(:lower)] = send(attribute) end end end |
#defaults ⇒ Object
12 13 14 |
# File 'lib/pdf4me/models/base.rb', line 12 def defaults {} end |