Module: AbcJsonapi::Serializer::ClassMethods
- Defined in:
- lib/abc_jsonapi/serializer.rb
Instance Method Summary collapse
- #attribute(name, &block) ⇒ Object
- #attributes(*attributes) ⇒ Object
- #belongs_to(relationship, &block) ⇒ Object
- #has_many(relationship, &block) ⇒ Object
- #has_one(relationship, &block) ⇒ Object
- #resource_type(rtype = nil) ⇒ Object
Instance Method Details
#attribute(name, &block) ⇒ Object
60 61 62 |
# File 'lib/abc_jsonapi/serializer.rb', line 60 def attribute(name, &block) virtual_attributes << { name: name, block: block } end |
#attributes(*attributes) ⇒ Object
40 41 42 |
# File 'lib/abc_jsonapi/serializer.rb', line 40 def attributes(*attributes) @resource_attributes = attributes end |
#belongs_to(relationship, &block) ⇒ Object
52 53 54 |
# 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) ⇒ Object
48 49 50 |
# 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) ⇒ Object
44 45 46 |
# 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) ⇒ Object
56 57 58 |
# File 'lib/abc_jsonapi/serializer.rb', line 56 def resource_type(rtype = nil) resource_type ||= rtype || Helpers.pluralize_if_necessary(default_type) end |