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

Version Path
jsonapi_compliable-0.6.4 lib/jsonapi_compliable/extensions/boolean_attribute.rb
jsonapi_compliable-0.6.3 lib/jsonapi_compliable/extensions/boolean_attribute.rb
jsonapi_compliable-0.6.2 lib/jsonapi_compliable/extensions/boolean_attribute.rb
jsonapi_compliable-0.6.1 lib/jsonapi_compliable/extensions/boolean_attribute.rb
jsonapi_compliable-0.6.0 lib/jsonapi_compliable/extensions/boolean_attribute.rb
jsonapi_compliable-0.5.7 lib/jsonapi_compliable/extensions/boolean_attribute.rb
jsonapi_compliable-0.5.6 lib/jsonapi_compliable/extensions/boolean_attribute.rb
jsonapi_compliable-0.5.5 lib/jsonapi_compliable/extensions/boolean_attribute.rb
jsonapi_compliable-0.5.4 lib/jsonapi_compliable/extensions/boolean_attribute.rb
jsonapi_compliable-0.5.3 lib/jsonapi_compliable/extensions/boolean_attribute.rb
jsonapi_compliable-0.5.2 lib/jsonapi_compliable/extensions/boolean_attribute.rb
jsonapi_compliable-0.5.1 lib/jsonapi_compliable/extensions/boolean_attribute.rb
jsonapi_compliable-0.4.0 lib/jsonapi_compliable/extensions/boolean_attribute.rb