Class: ModelScope::Callback
- Inherits:
-
Object
- Object
- ModelScope::Callback
- Defined in:
- lib/modelscope/callback.rb
Instance Attribute Summary collapse
-
#association_generated ⇒ Object
readonly
Returns the value of attribute association_generated.
-
#attribute_generated ⇒ Object
readonly
Returns the value of attribute attribute_generated.
-
#conditional ⇒ Object
readonly
Returns the value of attribute conditional.
-
#inherited ⇒ Object
readonly
Returns the value of attribute inherited.
-
#kind ⇒ Object
readonly
Returns the value of attribute kind.
-
#method_name ⇒ Object
readonly
Returns the value of attribute method_name.
-
#model ⇒ Object
readonly
Returns the value of attribute model.
-
#origin ⇒ Object
readonly
Returns the value of attribute origin.
Instance Method Summary collapse
- #callback_group ⇒ Object
- #human_method_name ⇒ Object
-
#initialize(model:, rails_callback:, name:, defining_class:) ⇒ Callback
constructor
A new instance of Callback.
- #validation_type ⇒ Object
Constructor Details
#initialize(model:, rails_callback:, name:, defining_class:) ⇒ Callback
Returns a new instance of Callback.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/modelscope/callback.rb', line 8 def initialize(model:, rails_callback:, name:, defining_class:) @model = model @callback = rails_callback @name = name @defining_class = defining_class analyzer = Analyzers::CallbackAnalyzer.new(@callback, model, defining_class) @kind = @callback.kind @method_name = @callback.filter @conditional = analyzer.conditional? @origin = analyzer.origin @inherited = analyzer.inherited? @association_generated = analyzer.association_generated? @attribute_generated = analyzer.attribute_generated? end |
Instance Attribute Details
#association_generated ⇒ Object (readonly)
Returns the value of attribute association_generated.
5 6 7 |
# File 'lib/modelscope/callback.rb', line 5 def association_generated @association_generated end |
#attribute_generated ⇒ Object (readonly)
Returns the value of attribute attribute_generated.
5 6 7 |
# File 'lib/modelscope/callback.rb', line 5 def attribute_generated @attribute_generated end |
#conditional ⇒ Object (readonly)
Returns the value of attribute conditional.
5 6 7 |
# File 'lib/modelscope/callback.rb', line 5 def conditional @conditional end |
#inherited ⇒ Object (readonly)
Returns the value of attribute inherited.
5 6 7 |
# File 'lib/modelscope/callback.rb', line 5 def inherited @inherited end |
#kind ⇒ Object (readonly)
Returns the value of attribute kind.
5 6 7 |
# File 'lib/modelscope/callback.rb', line 5 def kind @kind end |
#method_name ⇒ Object (readonly)
Returns the value of attribute method_name.
5 6 7 |
# File 'lib/modelscope/callback.rb', line 5 def method_name @method_name end |
#model ⇒ Object (readonly)
Returns the value of attribute model.
5 6 7 |
# File 'lib/modelscope/callback.rb', line 5 def model @model end |
#origin ⇒ Object (readonly)
Returns the value of attribute origin.
5 6 7 |
# File 'lib/modelscope/callback.rb', line 5 def origin @origin end |
Instance Method Details
#callback_group ⇒ Object
25 26 27 |
# File 'lib/modelscope/callback.rb', line 25 def callback_group @name.to_s end |
#human_method_name ⇒ Object
34 35 36 |
# File 'lib/modelscope/callback.rb', line 34 def human_method_name Analyzers::ValidationAnalyzer.human_method_name(@callback.filter) end |
#validation_type ⇒ Object
29 30 31 32 |
# File 'lib/modelscope/callback.rb', line 29 def validation_type return nil unless callback_group == "validate" Analyzers::ValidationAnalyzer.detect_type(@callback.filter, model) end |