Module: Trailblazer::Finder::Base

Included in:
Trailblazer::Finder
Defined in:
lib/trailblazer/finder/base.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#errorsObject (readonly)

Returns the value of attribute errors.



13
14
15
# File 'lib/trailblazer/finder/base.rb', line 13

def errors
  @errors
end

#signalObject (readonly)

Returns the value of attribute signal.



13
14
15
# File 'lib/trailblazer/finder/base.rb', line 13

def signal
  @signal
end

Class Method Details

.included(base) ⇒ Object



7
8
9
10
11
# File 'lib/trailblazer/finder/base.rb', line 7

def self.included(base)
  base.include Helpers::Basic
  base.include Helpers::Sorting
  base.extend Dsl
end

Instance Method Details

#fetch_resultObject



24
25
26
27
28
# File 'lib/trailblazer/finder/base.rb', line 24

def fetch_result
  result = @find.query self
  result = Utils::Array.convert_hashes_in_array_to_struct(result) if result.first.is_a?(Hash)
  result
end

#initialize(options = {}) ⇒ Object

rubocop:disable Style/OptionHash



15
16
17
18
19
20
21
22
# File 'lib/trailblazer/finder/base.rb', line 15

def initialize(options = {}) # rubocop:disable Style/OptionHash
  config = self.class.config
  ctx = {config: config, options: options}
  @signal, (ctx, *) = Activities::Find.call([ctx, {}])
  @options = options
  @errors = ctx[:errors] || {}
  @find = ctx[:finder]
end