module JsonapiAmsExtensions::ClassMethods
Public Instance Methods
boolean_attribute(name, *args)
click to toggle source
# File lib/jsonapi_ams_extensions.rb, line 44 def boolean_attribute(name, *args) is_method = :"is_#{name.to_s.sub('?', '')}" attribute(is_method, *args) define_method(is_method) do object.read_attribute_for_serialization(name) end end
boolean_attributes(*attributes)
click to toggle source
# File lib/jsonapi_ams_extensions.rb, line 53 def boolean_attributes(*attributes) attributes.each do |attr| boolean_attribute(attr) end end
extra_attribute(name)
click to toggle source
# File lib/jsonapi_ams_extensions.rb, line 26 def extra_attribute(name) attribute name, if: :"allow_#{name}?" define_method :"allow_#{name}?" do if extra_fields = instance_options[:extra_fields] if extra_fields = extra_fields[ResourceType.for(self)] extra_fields.include?(name) end end end end
extra_attributes(*names)
click to toggle source
# File lib/jsonapi_ams_extensions.rb, line 38 def extra_attributes(*names) names.each do |name| extra_attribute(name) end end