Class: Locomotive::Mounter::Models::Snippet
- Defined in:
- lib/locomotive/mounter/models/snippet.rb
Instance Attribute Summary
Attributes inherited from Base
#_id, #created_at, #mounting_point, #updated_at
Instance Method Summary collapse
-
#name ⇒ Object
fields ##.
-
#source ⇒ String
Return the Liquid template based on the template_filepath property of the snippet.
-
#to_params ⇒ Hash
Return the params used for the API.
- #to_s ⇒ Object
Methods inherited from Base
Methods included from Fields
#[], #attributes, #attributes_with_translations, #initialize, #localized_field?, #to_hash, #to_yaml, #translated_in, #translated_in?, #write_attributes
Constructor Details
This class inherits a constructor from Locomotive::Mounter::Models::Base
Instance Method Details
#name ⇒ Object
fields ##
8 |
# File 'lib/locomotive/mounter/models/snippet.rb', line 8 field :name |
#source ⇒ String
Return the Liquid template based on the template_filepath property of the snippet. If the template is HAML, then a pre-rendering to Liquid is done.
20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/locomotive/mounter/models/snippet.rb', line 20 def source @source ||= {} source = if self.template.respond_to?(:source) # liquid or haml file self.template.source else # simple string self.template end @source[Locomotive::Mounter.locale] = source end |
#to_params ⇒ Hash
Return the params used for the API.
38 39 40 41 42 43 44 45 |
# File 'lib/locomotive/mounter/models/snippet.rb', line 38 def to_params params = self.filter_attributes %w(name slug) # raw_template params[:template] = self.source rescue nil params end |
#to_s ⇒ Object
47 48 49 |
# File 'lib/locomotive/mounter/models/snippet.rb', line 47 def to_s self.name end |