module AbcJsonapi::Serializer::ClassMethods
Public Instance Methods
attribute(name, &block)
click to toggle source
# File lib/abc_jsonapi/serializer.rb, line 60 def attribute(name, &block) virtual_attributes << { name: name, block: block } end
attributes(*attributes)
click to toggle source
# File lib/abc_jsonapi/serializer.rb, line 40 def attributes(*attributes) @resource_attributes = attributes end
belongs_to(relationship, &block)
click to toggle source
# File lib/abc_jsonapi/serializer.rb, line 52 def belongs_to(relationship, &block) relationships << { type: :belongs_to, name: relationship, block: block } end
has_many(relationship, &block)
click to toggle source
# File lib/abc_jsonapi/serializer.rb, line 48 def has_many(relationship, &block) relationships << { type: :has_many, name: relationship, block: block } end
has_one(relationship, &block)
click to toggle source
# File lib/abc_jsonapi/serializer.rb, line 44 def has_one(relationship, &block) relationships << { type: :has_one, name: relationship, block: block } end
resource_type(rtype = nil)
click to toggle source
# File lib/abc_jsonapi/serializer.rb, line 56 def resource_type(rtype = nil) resource_type ||= rtype || Helpers.pluralize_if_necessary(default_type) end
Private Instance Methods
default_type()
click to toggle source
# File lib/abc_jsonapi/serializer.rb, line 72 def default_type self.to_s[/(\w+)Serializer$/, 1].tableize end