Class: ActiveRecord::Events::Naming
- Inherits:
-
Object
- Object
- ActiveRecord::Events::Naming
- Defined in:
- lib/active_record/events/naming.rb
Instance Method Summary collapse
- #action ⇒ Object
- #collective_action ⇒ Object
- #field ⇒ Object
-
#initialize(infinitive, options = {}) ⇒ Naming
constructor
A new instance of Naming.
- #inverse_predicate ⇒ Object
- #inverse_scope ⇒ Object
- #predicate ⇒ Object
- #safe_action ⇒ Object
- #scope ⇒ Object
Constructor Details
#initialize(infinitive, options = {}) ⇒ Naming
Returns a new instance of Naming.
6 7 8 9 10 |
# File 'lib/active_record/events/naming.rb', line 6 def initialize(infinitive, = {}) @infinitive = infinitive @object = [:object].presence @field_type = [:field_type].try(:to_sym) end |
Instance Method Details
#action ⇒ Object
25 26 27 |
# File 'lib/active_record/events/naming.rb', line 25 def action concatenate(infinitive, object) + '!' end |
#collective_action ⇒ Object
33 34 35 |
# File 'lib/active_record/events/naming.rb', line 33 def collective_action concatenate(infinitive, 'all', plural_object) end |
#field ⇒ Object
12 13 14 15 |
# File 'lib/active_record/events/naming.rb', line 12 def field suffix = field_type == :date ? 'on' : 'at' concatenate(object, past_participle, suffix) end |
#inverse_predicate ⇒ Object
21 22 23 |
# File 'lib/active_record/events/naming.rb', line 21 def inverse_predicate concatenate(object, 'not', past_participle) + '?' end |
#inverse_scope ⇒ Object
41 42 43 |
# File 'lib/active_record/events/naming.rb', line 41 def inverse_scope concatenate(object, 'not', past_participle) end |
#predicate ⇒ Object
17 18 19 |
# File 'lib/active_record/events/naming.rb', line 17 def predicate concatenate(object, past_participle) + '?' end |
#safe_action ⇒ Object
29 30 31 |
# File 'lib/active_record/events/naming.rb', line 29 def safe_action concatenate(infinitive, object) end |
#scope ⇒ Object
37 38 39 |
# File 'lib/active_record/events/naming.rb', line 37 def scope concatenate(object, past_participle) end |