sbfaulkner-sequel_container 1.0.4 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.markdown +8 -2
- data/lib/sequel_container.rb +14 -1
- data/sequel_container.gemspec +1 -1
- metadata +2 -2
data/README.markdown
CHANGED
@@ -28,9 +28,15 @@ Install the gem(s):
|
|
28
28
|
bytea :avatar_data
|
29
29
|
end
|
30
30
|
is :container, :tmp => File.dirname(__FILE__) + '/tmp'
|
31
|
-
contains :avatar
|
31
|
+
contains :avatar, :url => '/images/avatars/:id.:extension'
|
32
32
|
end
|
33
|
-
|
33
|
+
|
34
|
+
## CHANGES
|
35
|
+
|
36
|
+
### 1.1.0
|
37
|
+
|
38
|
+
- added support for :url option on contains to specify custom url path
|
39
|
+
|
34
40
|
## TODO
|
35
41
|
|
36
42
|
- include logic for image width and height
|
data/lib/sequel_container.rb
CHANGED
@@ -12,6 +12,7 @@ module Sequel
|
|
12
12
|
return object.each { |o| contains(o, options) } if object.is_a? Array
|
13
13
|
|
14
14
|
container = table_name
|
15
|
+
url_template = options[:url] || '/:container/:id/:filename'
|
15
16
|
|
16
17
|
class_eval <<-CONTAINED_PATH, __FILE__, __LINE__ + 1
|
17
18
|
def #{object}_path
|
@@ -24,7 +25,19 @@ module Sequel
|
|
24
25
|
def #{object}_url
|
25
26
|
return unless #{object}?
|
26
27
|
@#{object}_path ||= write_#{object}
|
27
|
-
@#{object}_url ||= "
|
28
|
+
@#{object}_url ||= "#{url_template}".gsub(/:(\\w+)/) do |m|
|
29
|
+
sym = $1.to_sym
|
30
|
+
case sym
|
31
|
+
when :container
|
32
|
+
"#{container}"
|
33
|
+
when :filename
|
34
|
+
send("#{object}_filename")
|
35
|
+
when :extension
|
36
|
+
send("#{object}_extension")
|
37
|
+
else
|
38
|
+
send(sym)
|
39
|
+
end
|
40
|
+
end
|
28
41
|
end
|
29
42
|
CONTAINED_URL
|
30
43
|
|
data/sequel_container.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sbfaulkner-sequel_container
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- S. Brent Faulkner
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-02-03 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|