Class: ActiveRecord::Events::MethodFactory
- Inherits:
-
Object
- Object
- ActiveRecord::Events::MethodFactory
- Defined in:
- lib/active_record/events/method_factory.rb
Instance Method Summary collapse
- #class_methods ⇒ Object
-
#initialize(event_name, options) ⇒ MethodFactory
constructor
A new instance of MethodFactory.
- #instance_methods ⇒ Object
Constructor Details
#initialize(event_name, options) ⇒ MethodFactory
Returns a new instance of MethodFactory.
6 7 8 9 10 11 |
# File 'lib/active_record/events/method_factory.rb', line 6 def initialize(event_name, ) = @naming = Naming.new(event_name, ) @strategy = [:strategy].try(:to_sym) @field_type = [:field_type].try(:to_sym) end |
Instance Method Details
#class_methods ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/active_record/events/method_factory.rb', line 23 def class_methods Module.new.tap do |module_| time_class = field_type == :date ? Date : Time define_collective_action_method(module_, naming, time_class) unless [:skip_scopes] define_scope_method(module_, naming, strategy, time_class) define_inverse_scope_method(module_, naming, strategy, time_class) end end end |
#instance_methods ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/active_record/events/method_factory.rb', line 13 def instance_methods Module.new.tap do |module_| define_predicate_method(module_, naming, strategy) define_inverse_predicate_method(module_, naming) define_action_method(module_, naming) define_safe_action_method(module_, naming) end end |