hat-trick 0.2.2 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Changelog +4 -0
- data/hat-trick.gemspec +1 -1
- data/lib/hat_trick/controller_hooks.rb +3 -0
- data/lib/hat_trick/dsl.rb +4 -2
- data/lib/hat_trick/model_methods.rb +18 -1
- data/lib/hat_trick/version.rb +1 -1
- metadata +4 -4
data/Changelog
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
* 0.3.0 - Add model_class DSL method to explicitly tell hat-trick which model to use.
|
2
|
+
- Clean up validation_groups on models after each request.
|
3
|
+
- Stop monkey-patching all of ActiveRecord::Base with hat-trick's model methods.
|
4
|
+
|
1
5
|
* 0.2.2 - Lower logging severity to debug for all of the formerly info-level logging output.
|
2
6
|
|
3
7
|
* 0.2.1 - Fix a bug where button_to data was shared across multiple users of the app. They are now user-specific, as they should be.
|
data/hat-trick.gemspec
CHANGED
@@ -22,7 +22,7 @@ Gem::Specification.new do |s|
|
|
22
22
|
s.add_development_dependency "mocha"
|
23
23
|
s.add_development_dependency "debugger"
|
24
24
|
|
25
|
-
s.add_runtime_dependency "rails", "
|
25
|
+
s.add_runtime_dependency "rails", ">= 3.1"
|
26
26
|
s.add_runtime_dependency "validation_group"
|
27
27
|
s.add_runtime_dependency "gon"
|
28
28
|
end
|
@@ -22,6 +22,9 @@ module HatTrick
|
|
22
22
|
end
|
23
23
|
common_hook(*args) if respond_to?(:common_hook, :include_private)
|
24
24
|
#{meth}_without_hat_trick(*args)
|
25
|
+
if hat_trick_wizard.model && hat_trick_wizard.model.respond_to?(:disable_validation_groups)
|
26
|
+
hat_trick_wizard.model.disable_validation_groups
|
27
|
+
end
|
25
28
|
end
|
26
29
|
private "#{meth}_with_hat_trick"
|
27
30
|
RUBY_EVAL
|
data/lib/hat_trick/dsl.rb
CHANGED
@@ -80,8 +80,6 @@ module HatTrick
|
|
80
80
|
include HatTrick::DSL::ControllerInstanceMethods
|
81
81
|
include HatTrick::ControllerHooks
|
82
82
|
|
83
|
-
::ActiveRecord::Base.send(:include, HatTrick::ModelMethods)
|
84
|
-
|
85
83
|
config = HatTrick::Config.new
|
86
84
|
@wizard_def = HatTrick::WizardDefinition.new(config)
|
87
85
|
|
@@ -97,6 +95,10 @@ module HatTrick
|
|
97
95
|
self.configure_callback = block
|
98
96
|
end
|
99
97
|
|
98
|
+
def model_class(klass)
|
99
|
+
klass.send(:include, HatTrick::ModelMethods)
|
100
|
+
end
|
101
|
+
|
100
102
|
def button_label(type, label)
|
101
103
|
wizard_def.config.send("#{type}_button_label=", label)
|
102
104
|
end
|
@@ -18,7 +18,9 @@ module HatTrick
|
|
18
18
|
def self.set_current_validation_group_for(klass, validation_group_name, dynamic)
|
19
19
|
self.validation_groups ||= {}
|
20
20
|
validation_groups[klass.to_s.underscore] = validation_group_name
|
21
|
-
|
21
|
+
if dynamic && !dynamic_validation_groups.include?(validation_group_name)
|
22
|
+
dynamic_validation_groups << validation_group_name
|
23
|
+
end
|
22
24
|
end
|
23
25
|
|
24
26
|
def self.current_validation_group_for(klass)
|
@@ -26,11 +28,26 @@ module HatTrick
|
|
26
28
|
validation_groups[klass.to_s.underscore]
|
27
29
|
end
|
28
30
|
|
31
|
+
def self.clear_current_validation_group_for(klass)
|
32
|
+
unless validation_groups.nil?
|
33
|
+
Rails.logger.debug "Clearing current validation groups for #{klass.to_s.underscore}"
|
34
|
+
validation_groups.delete klass.to_s.underscore
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
29
38
|
def perform_validations_with_hat_trick(*args, &block)
|
30
39
|
enable_current_validation_group
|
31
40
|
perform_validations_without_hat_trick(*args, &block)
|
32
41
|
end
|
33
42
|
|
43
|
+
def disable_validation_groups
|
44
|
+
if respond_to?(:disable_validation_group)
|
45
|
+
Rails.logger.debug "Disabling validation groups"
|
46
|
+
disable_validation_group
|
47
|
+
end
|
48
|
+
HatTrick::ModelMethods.clear_current_validation_group_for(self.class)
|
49
|
+
end
|
50
|
+
|
34
51
|
def as_json_with_model_name(*args, &block)
|
35
52
|
json = as_json_without_model_name(*args, &block)
|
36
53
|
json.merge! :__name__ => self.class.to_s.underscore if json.respond_to?(:merge!)
|
data/lib/hat_trick/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hat-trick
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-07-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
@@ -64,7 +64,7 @@ dependencies:
|
|
64
64
|
requirement: !ruby/object:Gem::Requirement
|
65
65
|
none: false
|
66
66
|
requirements:
|
67
|
-
- -
|
67
|
+
- - ! '>='
|
68
68
|
- !ruby/object:Gem::Version
|
69
69
|
version: '3.1'
|
70
70
|
type: :runtime
|
@@ -72,7 +72,7 @@ dependencies:
|
|
72
72
|
version_requirements: !ruby/object:Gem::Requirement
|
73
73
|
none: false
|
74
74
|
requirements:
|
75
|
-
- -
|
75
|
+
- - ! '>='
|
76
76
|
- !ruby/object:Gem::Version
|
77
77
|
version: '3.1'
|
78
78
|
- !ruby/object:Gem::Dependency
|