module JSONAPI::Attributes

Public Class Methods

included(target) click to toggle source
# File lib/jsonapi-serializers/attributes.rb, line 3
def self.included(target)
  target.send(:include, InstanceMethods)
  target.extend ClassMethods

  target.class_eval do
    def self.inherited(target)
      [:attributes_map, :to_one_associations, :to_many_associations]
        .each{|k|
          key = "@#{k}"
          attr = self.instance_variable_get(key)
          target.instance_variable_set(key, attr.dup) if attr
        }
    end
  end
end
inherited(target) click to toggle source
# File lib/jsonapi-serializers/attributes.rb, line 8
def self.inherited(target)
  [:attributes_map, :to_one_associations, :to_many_associations]
    .each{|k|
      key = "@#{k}"
      attr = self.instance_variable_get(key)
      target.instance_variable_set(key, attr.dup) if attr
    }
end