Module: Graphiti::Extensions::BooleanAttribute::ClassMethods

Defined in:
lib/graphiti/extensions/boolean_attribute.rb

Instance Method Summary collapse

Instance Method Details

#boolean_attribute(name, options = {}, &blk) ⇒ Object

Register a boolean attribute

Parameters:

  • name

    the corresponding ? method

  • options (Hash) (defaults to: {})

    Normal .attribute options



21
22
23
24
25
# File 'lib/graphiti/extensions/boolean_attribute.rb', line 21

def boolean_attribute(name, options = {}, &blk)
  blk ||= proc { @object.public_send(name) }
  field_name = :"is_#{name.to_s.delete("?")}"
  attribute field_name, options, &blk
end