class Blueprinter::Field

def callable_from(condition)

def callable_from(condition)
  config = Blueprinter.configuration
  # Use field-level callable, or when not defined, try global callable
  tmp = if options.key?(condition)
          options.fetch(condition)
        elsif config.valid_callable?(condition)
          config.public_send(condition)
        end
  return false unless tmp
  case tmp
  when Proc then tmp
  when Symbol then blueprint.method(tmp)
  else
    raise ArgumentError, "#{tmp.class} is passed to :#{condition}"
  end
end

def extract(object, local_options)

def extract(object, local_options)
  extractor.extract(method, object, local_options, options)
end

def if_callable

def if_callable
  return @if_callable if defined?(@if_callable)
  @if_callable = callable_from(:if)
end

def initialize(method, name, extractor, blueprint, options = {})

def initialize(method, name, extractor, blueprint, options = {})
  @method = method
  @name = name
  @extractor = extractor
  @blueprint = blueprint
  @options = options
end

def skip?(field_name, object, local_options)

def skip?(field_name, object, local_options)
  return true if if_callable && !if_callable.call(field_name, object, local_options)
  unless_callable && unless_callable.call(field_name, object, local_options)
end

def unless_callable

def unless_callable
  return @unless_callable if defined?(@unless_callable)
  @unless_callable = callable_from(:unless)
end