public
Fork of halorgium/mephisto
Description: A mirror of the mephisto code-base
Homepage: http://mephistoblog.com/
Clone URL: git://github.com/technoweenie/mephisto.git
Click here to lend your support to: mephisto and make a donation at www.pledgie.com !
mephisto / app / drops / asset_drop.rb
100644 26 lines (20 sloc) 0.572 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
class AssetDrop < BaseDrop
  def asset() @source end
 
  def initialize(source)
    @source = source
    super source
    @site_liquid = [:id, :content_type, :size, :filename, :width, :height].inject({}) { |h, k| h.merge k.to_s => @source.send(k) }
  end
 
  def before_method(method)
    @site_liquid[method.to_s]
  end
 
  [:image, :movie, :audio, :other, :pdf].each do |content|
    define_method("is_#{content}") { @source.send("#{content}?") }
  end
  
  def tags
    @tags ||= @source.tags.collect &:name
  end
 
  def path
    @path = @source.public_filename
  end
end