Welcome to mirror list, hosted at ThFree Co, Russian Federation.

expose_attribute.rb « representation « github_import « gitlab « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: d2438ee8094fc36d301d7df83cbf69d9eea41855 (plain)
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
# frozen_string_literal: true

module Gitlab
  module GithubImport
    module Representation
      module ExposeAttribute
        extend ActiveSupport::Concern

        class_methods do
          # Defines getter methods for the given attribute names.
          #
          # Example:
          #
          #     expose_attribute :iid, :title
          def expose_attribute(*names)
            names.each do |name|
              name = name.to_sym

              define_method(name) { attributes[name] }
            end
          end
        end
      end
    end
  end
end