Parent

Enumerize::Predicates::Builder

Public Class Methods

new(attr, options) click to toggle source
# File lib/enumerize/predicates.rb, line 44
def initialize(attr, options)
  @attr    = attr
  @options = options.is_a?(Hash) ? options : {}
end

Public Instance Methods

build(klass) click to toggle source
# File lib/enumerize/predicates.rb, line 67
def build(klass)
  klass.delegate(*names, to: @attr.name, prefix: @options[:prefix], allow_nil: true)
end
names() click to toggle source
# File lib/enumerize/predicates.rb, line 63
def names
  values.map { |v| "#{v}?" }
end
values() click to toggle source
# File lib/enumerize/predicates.rb, line 49
def values
  values = @attr.values

  if @options[:only]
    values &= Array(@options[:only]).map(&:to_s)
  end

  if @options[:except]
    values -= Array(@options[:except]).map(&:to_s)
  end

  values
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.