Class: Orthoses::ActiveRecord::QueryMethods
- Inherits:
-
Object
- Object
- Orthoses::ActiveRecord::QueryMethods
- Defined in:
- lib/orthoses/active_record/query_methods.rb
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(loader) ⇒ QueryMethods
constructor
A new instance of QueryMethods.
Constructor Details
#initialize(loader) ⇒ QueryMethods
Returns a new instance of QueryMethods.
6 7 8 |
# File 'lib/orthoses/active_record/query_methods.rb', line 6 def initialize(loader) @loader = loader end |
Instance Method Details
#call ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/orthoses/active_record/query_methods.rb', line 10 def call @loader.call.tap do |store| content = store["ActiveRecord::QueryMethods"] ::ActiveRecord::Relation::VALUE_METHODS.each do |name| method_name, type = case name when *::ActiveRecord::Relation::MULTI_VALUE_METHODS ["#{name}_values", "::Array[untyped]"] when *::ActiveRecord::Relation::SINGLE_VALUE_METHODS ["#{name}_value", name == :create_with ? "::Hash[untyped, untyped]?" : "untyped"] when *::ActiveRecord::Relation::CLAUSE_METHODS ["#{name}_clause", name == :from ? "::ActiveRecord::Relation::FromClause" : "::ActiveRecord::Relation::WhereClause"] end content << "def #{method_name}: () -> #{type}" content << "def #{method_name}=: (#{type} value) -> #{type}" end end end |