Class: Trailblazer::Finder::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/trailblazer/finder/dsl.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/trailblazer/finder/dsl.rb', line 6

def initialize
  @state = Trailblazer::Declarative::State(
    entity: [nil, {}],
    paging: [{}, {}],
    properties: [{}, {}],
    sorting: [{}, {}],
    filters: [{}, {}],
    adapter: ["Basic", {}],
    paginator: [nil, {}]
  )
end

Instance Attribute Details

#stateObject (readonly)

Returns the value of attribute state.



4
5
6
# File 'lib/trailblazer/finder/dsl.rb', line 4

def state
  @state
end

Instance Method Details

#adapterObject



59
60
61
# File 'lib/trailblazer/finder/dsl.rb', line 59

def adapter
  state.get(:adapter)
end

#adapter=(value) ⇒ Object



63
64
65
# File 'lib/trailblazer/finder/dsl.rb', line 63

def adapter=(value)
  state.set!(:adapter, value)
end

#cloneObject

Clone the configuration by copying the state



76
77
78
79
80
# File 'lib/trailblazer/finder/dsl.rb', line 76

def clone
  new_config = Configuration.new
  new_config.instance_variable_set(:@state, @state.copy)
  new_config
end

#entityObject

Accessors that delegate to the state



19
20
21
# File 'lib/trailblazer/finder/dsl.rb', line 19

def entity
  state.get(:entity)
end

#entity=(value) ⇒ Object



23
24
25
# File 'lib/trailblazer/finder/dsl.rb', line 23

def entity=(value)
  state.set!(:entity, value)
end

#filtersObject



51
52
53
# File 'lib/trailblazer/finder/dsl.rb', line 51

def filters
  state.get(:filters)
end

#filters=(value) ⇒ Object



55
56
57
# File 'lib/trailblazer/finder/dsl.rb', line 55

def filters=(value)
  state.set!(:filters, value)
end

#paginatorObject



67
68
69
# File 'lib/trailblazer/finder/dsl.rb', line 67

def paginator
  state.get(:paginator)
end

#paginator=(value) ⇒ Object



71
72
73
# File 'lib/trailblazer/finder/dsl.rb', line 71

def paginator=(value)
  state.set!(:paginator, value)
end

#pagingObject



27
28
29
# File 'lib/trailblazer/finder/dsl.rb', line 27

def paging
  state.get(:paging)
end

#paging=(value) ⇒ Object



31
32
33
# File 'lib/trailblazer/finder/dsl.rb', line 31

def paging=(value)
  state.set!(:paging, value)
end

#propertiesObject



35
36
37
# File 'lib/trailblazer/finder/dsl.rb', line 35

def properties
  state.get(:properties)
end

#properties=(value) ⇒ Object



39
40
41
# File 'lib/trailblazer/finder/dsl.rb', line 39

def properties=(value)
  state.set!(:properties, value)
end

#sortingObject



43
44
45
# File 'lib/trailblazer/finder/dsl.rb', line 43

def sorting
  state.get(:sorting)
end

#sorting=(value) ⇒ Object



47
48
49
# File 'lib/trailblazer/finder/dsl.rb', line 47

def sorting=(value)
  state.set!(:sorting, value)
end