module JsonapiCompliable::Extensions::BooleanAttribute::ClassMethods

Public Instance Methods

boolean_attribute(name, options = {}, &blk) click to toggle source

Register a boolean attribute @param name the corresponding ? method @param [Hash] options Normal .attribute options

# File lib/jsonapi_compliable/extensions/boolean_attribute.rb, line 21
def boolean_attribute(name, options = {}, &blk)
  blk ||= proc { @object.public_send(name) }
  field_name = :"is_#{name.to_s.gsub('?', '')}"
  attribute field_name, options, &blk
end