File: attribute.rb

package info (click to toggle)
ruby-active-model-serializers 0.10.12-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,752 kB
  • sloc: ruby: 13,138; sh: 53; makefile: 6
file content (27 lines) | stat: -rw-r--r-- 669 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# frozen_string_literal: true

require 'active_model/serializer/field'

module ActiveModel
  class Serializer
    # Holds all the meta-data about an attribute as it was specified in the
    # ActiveModel::Serializer class.
    #
    # @example
    #   class PostSerializer < ActiveModel::Serializer
    #     attribute :content
    #     attribute :name, key: :title
    #     attribute :email, key: :author_email, if: :user_logged_in?
    #     attribute :preview do
    #       truncate(object.content)
    #     end
    #
    #     def user_logged_in?
    #       current_user.logged_in?
    #     end
    #   end
    #
    class Attribute < Field
    end
  end
end