Class: LedgerSync::Domains::Serializer::Query
- Inherits:
-
Object
- Object
- LedgerSync::Domains::Serializer::Query
- Defined in:
- lib/ledger_sync/domains/serializer/query.rb
Defined Under Namespace
Classes: SerializerReferencesManyType, SerializerReferencesOneType
Constant Summary collapse
- QUERY_METHODS =
%w[ distinct distinct! eager_load eager_load! extending extending! from from! group group! having having! includes includes! joins joins! left_outer_joins left_outer_joins! limit limit! offset offset! order order! preload preload! references references! unscope unscope! where where! load reload reset ].freeze
- READER_METHODS =
lock lock!
%w[ fifth fifth! find find_by find_by! first first! forty_two forty_two! fourth fourth! last last! second second! second_to_last second_to_last! third third! third_to_last third_to_last! ].freeze
- READERS_METHODS =
%w[find_each each map to_ary].freeze
- READERS_BATCH_METHODS =
in_batches does not make sense as it renders relation
%w[find_in_batches].freeze
- INSPECT_METHODS =
%w[ any? blank? empty? explain many? none? one? size to_sql exists? count ids maximum minimum sum none none! loaded? ].freeze
Instance Method Summary collapse
- #as_json(*_args) ⇒ Object
-
#initialize(serializer:, query:) ⇒ Query
constructor
A new instance of Query.
- #inspect(*_args) ⇒ Object
- #method_missing(name, *args, **params, &block) ⇒ Object
-
#respond_to_missing?(name, _include_private) ⇒ Boolean
pass through Enumerable methods.
Constructor Details
#initialize(serializer:, query:) ⇒ Query
Returns a new instance of Query.
7 8 9 10 |
# File 'lib/ledger_sync/domains/serializer/query.rb', line 7 def initialize(serializer:, query:) @query = query @serializer = serializer end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, **params, &block) ⇒ Object
95 96 97 98 99 |
# File 'lib/ledger_sync/domains/serializer/query.rb', line 95 def method_missing(name, *args, **params, &block) return super unless Enumerable.instance_methods.include?(name.to_sym) to_ary.send(name, *args, **params, &block) end |
Instance Method Details
#as_json(*_args) ⇒ Object
86 87 88 |
# File 'lib/ledger_sync/domains/serializer/query.rb', line 86 def as_json(*_args) to_ary.map!(&:as_json) end |
#inspect(*_args) ⇒ Object
78 79 80 81 82 83 84 |
# File 'lib/ledger_sync/domains/serializer/query.rb', line 78 def inspect(*_args) entries = to_ary.take(11).map!(&:inspect) entries[10] = '...' if entries.size == 11 "#<#{self.class.name} [#{entries.join(', ')}]>" end |
#respond_to_missing?(name, _include_private) ⇒ Boolean
pass through Enumerable methods
91 92 93 |
# File 'lib/ledger_sync/domains/serializer/query.rb', line 91 def respond_to_missing?(name, _include_private) Enumerable.instance_methods.include?(name.to_sym) end |