module Enumish

Constants

VERSION

Public Instance Methods

method_missing(method_id, *args, &block) click to toggle source

Allow calls such as object.friendly? or model.attitude.friendly?

Calls superclass method
# File lib/enumish.rb, line 36
def method_missing(method_id, *args, &block)
  bare_method = if method_id.to_s.match(/\?$/) && args.empty? && block.nil?
    method_id.to_s.sub(/\?$/, "")
  end

  if bare_method && self.class.enum_ids.include?(bare_method)
    self.send(self.class.enum_id.to_s) == bare_method
  else
    super
  end
end
to_s() click to toggle source
# File lib/enumish.rb, line 48
def to_s
  self.send(self.class.enum_id).to_s
end
to_sym() click to toggle source
# File lib/enumish.rb, line 52
def to_sym
  self.send(self.class.enum_id).to_sym
end