property_sets 0.3.4 → 0.3.5
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/VERSION +1 -1
- data/lib/property_sets/action_view_extension.rb +14 -2
- data/property_sets.gemspec +2 -2
- data/test/test_view_extensions.rb +20 -0
- metadata +4 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.5
|
@@ -28,18 +28,30 @@ module ActionView
|
|
28
28
|
template.radio_button(object_name, property, checked_value, options)
|
29
29
|
end
|
30
30
|
|
31
|
-
def
|
31
|
+
def hidden_field(property, options = {})
|
32
|
+
template.hidden_field(object_name, property, prepare_id_name(property, options))
|
33
|
+
end
|
34
|
+
|
35
|
+
def prepare_id_name(property, options)
|
36
|
+
throw "Invalid options type #{options.inspect}" unless options.is_a?(Hash)
|
37
|
+
|
32
38
|
instance = template.instance_variable_get("@#{object_name}")
|
39
|
+
|
33
40
|
throw "No @#{object_name} in scope" if instance.nil?
|
34
41
|
throw "The property_set_check_box only works on models with property set #{property_set}" unless instance.respond_to?(property_set)
|
35
42
|
|
36
43
|
options[:id] ||= "#{object_name}_#{property_set}_#{property}"
|
37
44
|
options[:name] = "#{object_name}[#{property_set}][#{property}]"
|
38
45
|
options[:object] = instance
|
39
|
-
options[:checked] = yield(instance.send(property_set))
|
40
46
|
|
41
47
|
options
|
42
48
|
end
|
49
|
+
|
50
|
+
def prepare_options(property, options, &block)
|
51
|
+
options = prepare_id_name(property, options)
|
52
|
+
options[:checked] = yield(options[:object].send(property_set))
|
53
|
+
options
|
54
|
+
end
|
43
55
|
end
|
44
56
|
|
45
57
|
def property_set(identifier)
|
data/property_sets.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{property_sets}
|
8
|
-
s.version = "0.3.
|
8
|
+
s.version = "0.3.5"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Morten Primdahl"]
|
12
|
-
s.date = %q{2011-03-
|
12
|
+
s.date = %q{2011-03-03}
|
13
13
|
s.description = %q{This gem is an ActiveRecord extension which provides a convenient interface for managing per row properties}
|
14
14
|
s.email = %q{morten@zendesk.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -51,6 +51,26 @@ class TestViewExtensions < ActiveSupport::TestCase
|
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
54
|
+
context "hidden_field" do
|
55
|
+
should "call with :value set" do
|
56
|
+
settings = stub(@property => "hello")
|
57
|
+
object = stub()
|
58
|
+
object.stubs(@association).returns(settings)
|
59
|
+
|
60
|
+
options = {
|
61
|
+
:value => "im hidden", :name => "object_name[#{@association}][#{@property}]",
|
62
|
+
:id => "object_name_#{@association}_#{@property}", :object => object
|
63
|
+
}
|
64
|
+
template = stub()
|
65
|
+
template.expects(:instance_variable_get).with("@object_name").returns(object)
|
66
|
+
# def hidden_field(object_name, method, options = {})
|
67
|
+
template.expects(:hidden_field).with("object_name", @property, options)
|
68
|
+
|
69
|
+
@proxy.stubs(:template).returns(template)
|
70
|
+
@proxy.hidden_field(@property, options)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
54
74
|
context "radio_button" do
|
55
75
|
should "call with checked true for a truth value" do
|
56
76
|
settings = stub(@property => "hello")
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: property_sets
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.3.
|
9
|
+
- 5
|
10
|
+
version: 0.3.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Morten Primdahl
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-03-
|
18
|
+
date: 2011-03-03 00:00:00 -08:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|