Class: Spree::Content

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/spree/content.rb

Constant Summary collapse

@@per_page =
10

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#delete_attachmentObject

Returns the value of attribute delete_attachment.



3
4
5
# File 'app/models/spree/content.rb', line 3

def delete_attachment
  @delete_attachment
end

Instance Method Details

#attachment_sizesObject



52
53
54
55
56
57
58
59
60
# File 'app/models/spree/content.rb', line 52

def attachment_sizes
  case self.context
    when 'slideshow'
      sizes = default_attachment_sizes.merge(:slide => '955x476#')
    else
      sizes = default_attachment_sizes
  end
  sizes
end

#context=(value) ⇒ Object



62
63
64
# File 'app/models/spree/content.rb', line 62

def context=(value)
  write_attribute :context, value.to_s.parameterize
end

#default_attachment_sizesObject



48
49
50
# File 'app/models/spree/content.rb', line 48

def default_attachment_sizes
  { :mini => '48x48>', :medium => '427x287>' }
end

#has_full_link?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'app/models/spree/content.rb', line 32

def has_full_link?
  has_link? && has_link_text?
end

#has_image?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'app/models/spree/content.rb', line 36

def has_image?
  has_value(:attachment_file_name) && attachment_file_name.match(/gif|jpg|png/i)
end

#hide_title?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'app/models/spree/content.rb', line 40

def hide_title?
  self.hide_title == true
end

#rendered_bodyObject



44
45
46
# File 'app/models/spree/content.rb', line 44

def rendered_body
  RDiscount.new(body.to_s).to_html.html_safe
end