super_map 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README +6 -4
- data/Rakefile +1 -1
- data/lib/super_map.rb +12 -5
- metadata +7 -7
data/README
CHANGED
@@ -37,14 +37,17 @@ We define 2 SuperMaps:
|
|
37
37
|
|
38
38
|
end
|
39
39
|
|
40
|
-
PAYMENT_TYPES defines options for payment_type field.
|
40
|
+
PAYMENT_TYPES defines options for payment_type field. First parameter is a key
|
41
|
+
that should be used to access this element instead of using value, which comes
|
42
|
+
second as integer (and is possibly stored in database). Note that value might be
|
43
|
+
totally random, it just needs be unique across elements. Some labels are set
|
41
44
|
explicitly, for other options key.titleize will be used implicitly. We also
|
42
45
|
defined a custom attribute :tax, which can be accessed using SuperMap#attribute
|
43
46
|
method.
|
44
47
|
|
45
48
|
PAYMENT_METHODS define translation_scope, which means labels will be present in
|
46
|
-
translations file (I18n). :paypal will have
|
47
|
-
translations.
|
49
|
+
translations file (I18n - note that it's totally optional). :paypal will have
|
50
|
+
custom label, which overrides translations.
|
48
51
|
|
49
52
|
We can than use those SuperMaps to handle attributes for Payment instances:
|
50
53
|
|
@@ -63,7 +66,6 @@ We can also use
|
|
63
66
|
to get the form directly suitable to pass options to f.select helper method.
|
64
67
|
|
65
68
|
|
66
|
-
|
67
69
|
To make things even simpler, we can use super_mapped_attr:
|
68
70
|
|
69
71
|
class Payment
|
data/Rakefile
CHANGED
@@ -14,7 +14,7 @@ PKG_FILES = FileList[
|
|
14
14
|
|
15
15
|
spec = Gem::Specification.new do |s|
|
16
16
|
s.name = "super_map"
|
17
|
-
s.version = "1.0.
|
17
|
+
s.version = "1.0.2"
|
18
18
|
s.author = "Marek Janukowicz"
|
19
19
|
s.email = "marek@janukowicz.net"
|
20
20
|
s.homepage = "http://www.bitbucket.org/starware/super_map"
|
data/lib/super_map.rb
CHANGED
@@ -1,9 +1,11 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
unless defined?( RAILS_ENV ) # We don't need these in Rails, as they are provided there
|
2
|
+
begin
|
3
|
+
require 'i18n'
|
4
|
+
rescue LoadError
|
5
|
+
nil # We don't really need I18n, but if it's not present, :translation_scope can't be used
|
6
|
+
end
|
7
|
+
require 'string_extensions'
|
5
8
|
end
|
6
|
-
require 'string_extensions'
|
7
9
|
require 'super_mapped_attr'
|
8
10
|
|
9
11
|
# Two-way hash with additional custom data, autogenerated labels and human
|
@@ -79,6 +81,11 @@ class SuperMap
|
|
79
81
|
|
80
82
|
# Creates new list.
|
81
83
|
# Elements - arrays with arguments for Element.new (key, value, attributes)
|
84
|
+
# key - a Symbol representing the element (to be used within the app to
|
85
|
+
# access this element)
|
86
|
+
# value - integer, string or whatever: real, meaningful value of element
|
87
|
+
# attributes - any additional attributes this element might need in form of
|
88
|
+
# a Hash
|
82
89
|
# Options (optional last argument):
|
83
90
|
# :translation_scope - where to find translated labels/descriptions
|
84
91
|
# :unknown_value_fatal - whether to raise an exception when accessing
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: super_map
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
9
|
+
- 2
|
10
|
+
version: 1.0.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Marek Janukowicz
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
18
|
+
date: 2011-02-23 00:00:00 +01:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|
@@ -30,12 +30,12 @@ extra_rdoc_files:
|
|
30
30
|
files:
|
31
31
|
- Rakefile
|
32
32
|
- README
|
33
|
-
- lib/super_map.rb
|
34
|
-
- lib/super_mapped_attr.rb
|
35
33
|
- lib/string_extensions.rb
|
34
|
+
- lib/super_mapped_attr.rb
|
35
|
+
- lib/super_map.rb
|
36
|
+
- test/super_map_test.rb
|
36
37
|
- test/super_mapped_attr_test.rb
|
37
38
|
- test/en.yml
|
38
|
-
- test/super_map_test.rb
|
39
39
|
has_rdoc: true
|
40
40
|
homepage: http://www.bitbucket.org/starware/super_map
|
41
41
|
licenses: []
|