Class: Statesman::Adapters::CustomActiveRecordQueries::ClassMethods
- Inherits:
-
Module
- Object
- Module
- Statesman::Adapters::CustomActiveRecordQueries::ClassMethods
- Defined in:
- lib/statesman/adapters/custom_active_record_queries.rb
Instance Method Summary collapse
- #included(base) ⇒ Object
-
#initialize(**args) ⇒ ClassMethods
constructor
A new instance of ClassMethods.
Constructor Details
#initialize(**args) ⇒ ClassMethods
Returns a new instance of ClassMethods.
11 12 13 |
# File 'lib/statesman/adapters/custom_active_record_queries.rb', line 11 def initialize(**args) @args = args end |
Instance Method Details
#included(base) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/statesman/adapters/custom_active_record_queries.rb', line 15 def included(base) ensure_inheritance(base) field_name = @args.delete(:field_name) query_builder = ::Statesman::Adapters::ActiveRecordQueries::QueryBuilder.new(base, **@args) join_name = :"#{field_name}_most_recent_transition_join" base.define_singleton_method(join_name) do query_builder.most_recent_transition_join end define_in_state(base, query_builder, join_name, field_name) define_not_in_state(base, query_builder, join_name, field_name) end |