Class: Stratus::Resources::Attachment
- Defined in:
- lib/stratus/resources/attachment.rb
Instance Attribute Summary collapse
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
Attributes inherited from Base
#collection_type, #content_path, #content_type, #index, #slug, #source_path
Instance Method Summary collapse
- #full_path ⇒ Object
-
#initialize(fullpath, content_object) ⇒ Attachment
constructor
A new instance of Attachment.
- #is_homepage? ⇒ Boolean
- #output_path ⇒ Object
- #validate! ⇒ Object
Methods inherited from Base
#<=>, #[], #[]=, #attachments, #attachments_hash, #fixup_meta, #is_homepage, #metadata, #method_missing, #next_content, #prev_content, #to_liquid
Constructor Details
#initialize(fullpath, content_object) ⇒ Attachment
7 8 9 10 11 12 13 |
# File 'lib/stratus/resources/attachment.rb', line 7 def initialize(fullpath, content_object) super(fullpath, content_object.content_path, :file) @parent = content_object @content_type = :attachment @content_path = parent.content_path @collection_type = parent.collection_type end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Stratus::Resources::Base
Instance Attribute Details
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
5 6 7 |
# File 'lib/stratus/resources/attachment.rb', line 5 def parent @parent end |
Instance Method Details
#full_path ⇒ Object
20 21 22 |
# File 'lib/stratus/resources/attachment.rb', line 20 def full_path "#{@parent.collection_type}/#{@parent.slug}/#{@slug}" end |
#is_homepage? ⇒ Boolean
28 29 30 |
# File 'lib/stratus/resources/attachment.rb', line 28 def is_homepage? false end |
#output_path ⇒ Object
24 25 26 |
# File 'lib/stratus/resources/attachment.rb', line 24 def output_path File.join(Stratus.output_dir, full_path) end |
#validate! ⇒ Object
15 16 17 18 |
# File 'lib/stratus/resources/attachment.rb', line 15 def validate! #raise StandardError.new("Posts must have a published-on date! #{content_path}") unless metadata.has_key?(:publish_on) true end |