Module: HatTrick::ModelMethods
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/hat_trick/model_methods.rb
Instance Attribute Summary collapse
-
#_dummy ⇒ Object
so the dummy field will have something to set.
Class Method Summary collapse
- .current_validation_group_for(klass) ⇒ Object
- .dynamic_validation_groups ⇒ Object
- .set_current_validation_group_for(klass, validation_group_name, dynamic) ⇒ Object
Instance Method Summary collapse
- #as_json_with_model_name(*args, &block) ⇒ Object
- #perform_validations_with_hat_trick(*args, &block) ⇒ Object
Instance Attribute Details
#_dummy ⇒ Object
so the dummy field will have something to set
7 8 9 |
# File 'lib/hat_trick/model_methods.rb', line 7 def _dummy @_dummy end |
Class Method Details
.current_validation_group_for(klass) ⇒ Object
24 25 26 27 |
# File 'lib/hat_trick/model_methods.rb', line 24 def self.current_validation_group_for(klass) return nil unless validation_groups validation_groups[klass.to_s.underscore] end |
.dynamic_validation_groups ⇒ Object
14 15 16 |
# File 'lib/hat_trick/model_methods.rb', line 14 def self.dynamic_validation_groups @dynamic_validation_groups ||= [] end |
.set_current_validation_group_for(klass, validation_group_name, dynamic) ⇒ Object
18 19 20 21 22 |
# File 'lib/hat_trick/model_methods.rb', line 18 def self.set_current_validation_group_for(klass, validation_group_name, dynamic) self.validation_groups ||= {} validation_groups[klass.to_s.underscore] = validation_group_name dynamic_validation_groups << validation_group_name if dynamic end |
Instance Method Details
#as_json_with_model_name(*args, &block) ⇒ Object
34 35 36 37 |
# File 'lib/hat_trick/model_methods.rb', line 34 def as_json_with_model_name(*args, &block) json = as_json_without_model_name(*args, &block) json.merge! :__name__ => self.class.to_s.underscore if json.respond_to?(:merge!) end |
#perform_validations_with_hat_trick(*args, &block) ⇒ Object
29 30 31 32 |
# File 'lib/hat_trick/model_methods.rb', line 29 def perform_validations_with_hat_trick(*args, &block) enable_current_validation_group perform_validations_without_hat_trick(*args, &block) end |