Sha256: e8cf696f26a40092c3fff920103e78005e4ba70f028c415e5d3d5ca76bfe737f
Contents?: true
Size: 535 Bytes
Versions: 13
Compression:
Stored size: 535 Bytes
Contents
module JsonapiCompliable module Extensions module BooleanAttribute def self.included(klass) klass.extend ClassMethods end module ClassMethods 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 end end end end JSONAPI::Serializable::Resource.class_eval do include JsonapiCompliable::Extensions::BooleanAttribute end
Version data entries
13 entries across 13 versions & 1 rubygems