Method: Fera::Base#method_missing

Defined in:
lib/fera/models/base.rb

#method_missing(method_name, *args, &block) ⇒ Object

Method missing adapters to define public_*_id



291
292
293
294
295
296
297
298
299
300
301
302
303
304
# File 'lib/fera/models/base.rb', line 291

def method_missing(method_name, *args, &block)
  matcher = method_name.to_s.match(/^(?!is_)([a-z_]+)\?$/) || method_name.to_s.match(/^is_([a-z_]+)\?$/)
  if matcher.present?
    attribute_name = matcher[1]
    return super if attribute_name.blank?

    attribute_name = "is_#{ attribute_name }" unless attribute_name =~ /^is_/
    return super unless known_attribute?(attribute_name.to_s)

    return !!send(attribute_name.to_sym).presence
  end

  super
end