class AgnosticBackend::Indexable::Field
Attributes
from[RW]
type[RW]
value[RW]
Public Class Methods
new(value, type, from: nil, **options)
click to toggle source
# File lib/agnostic_backend/indexable/field.rb, line 8 def initialize(value, type, from: nil, **options) if type == FieldType::STRUCT && from.nil? raise "A nested type requires the specification of a target class using the `from` argument" end @value = value.respond_to?(:call) ? value : value.to_sym @from = (from.is_a?(Enumerable) ? from : [from]) unless from.nil? @type = FieldType.new(type, **options) end
Public Instance Methods
evaluate(context:)
click to toggle source
# File lib/agnostic_backend/indexable/field.rb, line 17 def evaluate(context:) value.respond_to?(:call) ? context.instance_eval(&value) : context.send(value) end