yolk-biggs 0.1.1 → 0.1.2
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/CHANGES.textile +4 -0
- data/README.textile +10 -1
- data/VERSION.yml +1 -1
- data/lib/biggs/activerecord.rb +7 -1
- metadata +2 -2
data/CHANGES.textile
CHANGED
data/README.textile
CHANGED
@@ -59,7 +59,16 @@ You can customize the method-names biggs will use by passing in a hash of option
|
|
59
59
|
:street => Proc.new {|address| "#{address.street} #{address.house_number}" }
|
60
60
|
end
|
61
61
|
|
62
|
-
You can pass in a symbol to let biggs call a different method on your Address-model, or a Proc-object to create your data on the fly.
|
62
|
+
You can pass in a symbol to let biggs call a different method on your Address-model, or a Proc-object to create your data on the fly.
|
63
|
+
|
64
|
+
You can even pass in a array of symbols:
|
65
|
+
|
66
|
+
Address < ActiveRecord::Base
|
67
|
+
biggs :postal_address,
|
68
|
+
:recipient => [:company_name, :person_name]
|
69
|
+
end
|
70
|
+
|
71
|
+
This will call the methods company_name and person_name on your address-instance, remove any blank returned values and join the rest by a line break.
|
63
72
|
|
64
73
|
To access the formatted address string, simply call the provided method on an address instance:
|
65
74
|
|
data/VERSION.yml
CHANGED
data/lib/biggs/activerecord.rb
CHANGED
@@ -54,10 +54,16 @@ module Biggs
|
|
54
54
|
key = self.class.biggs_value_methods[field.to_sym] || field.to_sym
|
55
55
|
|
56
56
|
case key
|
57
|
-
when Symbol
|
57
|
+
when Symbol
|
58
58
|
self.send(key.to_sym)
|
59
59
|
when Proc
|
60
60
|
key.call(self).to_s
|
61
|
+
when Array
|
62
|
+
if key.all?{|it| it.is_a?(Symbol) }
|
63
|
+
key.map{|method| self.send(method) }.reject(&:blank?).join("\n")
|
64
|
+
else
|
65
|
+
raise "Biggs: Can't handle #{field} type Array with non-symbolic entries"
|
66
|
+
end
|
61
67
|
else
|
62
68
|
raise "Biggs: Can't handle #{field} type #{key.class}"
|
63
69
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yolk-biggs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sebastian Munz
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-03-
|
12
|
+
date: 2009-03-04 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|