Skip to content
This repository
Browse code

Removed AttachmentDefinition

git-svn-id: https://svn.thoughtbot.com/plugins/paperclip/trunk@393 7bbfaf0e-4d1d-0410-9690-a8bb5f8ef2aa
  • Loading branch information...
commit 1b8e626cee570de6f669cefd2998af3a57067277 1 parent d3af7c6
jyurek authored

Showing 1 changed file with 0 additions and 57 deletions. Show diff stats Hide diff stats

  1. +0 57 lib/paperclip/attachment_definition.rb
57 lib/paperclip/attachment_definition.rb
... ... @@ -1,57 +0,0 @@
1   -module Paperclip
2   -
3   - # Holds the options defined by a call to has_attached_file. If options are not defined here as methods
4   - # they will still be found through +method_missing+. Default values can be modified by modifying the
5   - # hash returned by AttachmentDefinition.defaults directly.
6   - class AttachmentDefinition
7   -
8   - def self.defaults
9   - @defaults ||= {
10   - :path => ":rails_root/public/:class/:attachment/:id/:style_:filename",
11   - :url => "/:class/:attachment/:id/:style_:filename",
12   - :missing_url => "/:class/:attachment/:style_missing.png",
13   - :styles => {},
14   - :delete_on_destroy => true,
15   - :default_style => :original
16   - }
17   - end
18   -
19   - def initialize name, options
20   - @name = name
21   - @options = AttachmentDefinition.defaults.merge options
22   - end
23   -
24   - def name
25   - @name
26   - end
27   -
28   - # A hash of all styles of the attachment, plus :original. If :original is specified
29   - # in the styles option, it will be overwritten.
30   - def styles
31   - @styles ||= @options[:styles].merge(:original => nil)
32   - end
33   -
34   - # A convenience method to insert validation options into the options hash
35   - # after the attachment has been defined.
36   - def validate thing, *constraints
37   - @options[:"validate_#{thing}"] = (constraints.length == 1 ? constraints.first : constraints)
38   - end
39   -
40   - def validations
41   - @validations ||= @options.inject({}) do |valids, opts|
42   - key, val = opts
43   - if (m = key.to_s.match(/^validates?_(.+)/))
44   - valids[m[1].to_sym] = val
45   - end
46   - valids
47   - end
48   - end
49   -
50   - # Any option passed in that does not explicitly appear in this class can be accessed through methods
51   - # regardless, as they are caught by +method_missing+. This does mean that it's probably not a good idea,
52   - # if you plan on extending Paperclip, to have an option that has the same name as a method on +Object+.
53   - def method_missing meth, *args
54   - @options[meth]
55   - end
56   - end
57   -end

0 comments on commit 1b8e626

Please sign in to comment.
Something went wrong with that request. Please try again.