Class: LcpRuby::Dsl::AdvancedFilterBuilder

Inherits:
Object
  • Object
show all
Includes:
SourceLocationCapture
Defined in:
lib/lcp_ruby/dsl/presenter_builder.rb

Instance Method Summary collapse

Methods included from SourceLocationCapture

capture_source_loc

Constructor Details

#initializeAdvancedFilterBuilder

Returns a new instance of AdvancedFilterBuilder.



1182
1183
1184
# File 'lib/lcp_ruby/dsl/presenter_builder.rb', line 1182

def initialize
  @hash = { "enabled" => true }
end

Instance Method Details

#allow_or_groups(value) ⇒ Object



1202
1203
1204
# File 'lib/lcp_ruby/dsl/presenter_builder.rb', line 1202

def allow_or_groups(value)
  @hash["allow_or_groups"] = value
end

#default_combinator(value) ⇒ Object



1198
1199
1200
# File 'lib/lcp_ruby/dsl/presenter_builder.rb', line 1198

def default_combinator(value)
  @hash["default_combinator"] = value.to_s
end

#enabled(value) ⇒ Object



1186
1187
1188
# File 'lib/lcp_ruby/dsl/presenter_builder.rb', line 1186

def enabled(value)
  @hash["enabled"] = value
end

#field_options(name, operators: nil) ⇒ Object



1222
1223
1224
1225
1226
1227
# File 'lib/lcp_ruby/dsl/presenter_builder.rb', line 1222

def field_options(name, operators: nil)
  @hash["field_options"] ||= {}
  opts = {}
  opts["operators"] = operators.map(&:to_s) if operators
  @hash["field_options"][name.to_s] = opts
end

#filterable_fields(*fields) ⇒ Object



1214
1215
1216
# File 'lib/lcp_ruby/dsl/presenter_builder.rb', line 1214

def filterable_fields(*fields)
  @hash["filterable_fields"] = fields.flatten.map(&:to_s)
end

#filterable_fields_except(*fields) ⇒ Object



1218
1219
1220
# File 'lib/lcp_ruby/dsl/presenter_builder.rb', line 1218

def filterable_fields_except(*fields)
  @hash["filterable_fields_except"] = fields.flatten.map(&:to_s)
end

#max_association_depth(value) ⇒ Object



1194
1195
1196
# File 'lib/lcp_ruby/dsl/presenter_builder.rb', line 1194

def max_association_depth(value)
  @hash["max_association_depth"] = value
end

#max_conditions(value) ⇒ Object



1190
1191
1192
# File 'lib/lcp_ruby/dsl/presenter_builder.rb', line 1190

def max_conditions(value)
  @hash["max_conditions"] = value
end

#max_nesting_depth(value) ⇒ Object



1210
1211
1212
# File 'lib/lcp_ruby/dsl/presenter_builder.rb', line 1210

def max_nesting_depth(value)
  @hash["max_nesting_depth"] = value
end

#preset(name, label:, conditions:) ⇒ Object



1229
1230
1231
1232
1233
1234
1235
1236
1237
# File 'lib/lcp_ruby/dsl/presenter_builder.rb', line 1229

def preset(name, label:, conditions:)
  @hash["presets"] ||= []
  @hash["presets"] << {
    "name" => name.to_s,
    "label" => label,
    "_label_source_loc" => capture_source_loc,
    "conditions" => conditions.map { |c| c.transform_keys(&:to_s) }
  }
end

#query_language(value) ⇒ Object



1206
1207
1208
# File 'lib/lcp_ruby/dsl/presenter_builder.rb', line 1206

def query_language(value)
  @hash["query_language"] = value
end

#saved_filters(&block) ⇒ Object



1239
1240
1241
1242
1243
# File 'lib/lcp_ruby/dsl/presenter_builder.rb', line 1239

def saved_filters(&block)
  builder = SavedFiltersBuilder.new
  builder.instance_eval(&block)
  @hash["saved_filters"] = builder.to_hash
end

#to_hashObject



1245
1246
1247
# File 'lib/lcp_ruby/dsl/presenter_builder.rb', line 1245

def to_hash
  @hash
end