summaryrefslogtreecommitdiff
path: root/lib/gitlab/github_import/representation/expose_attribute.rb
blob: c340575963167cce0452d66f44babcd11f950a84 (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

        module ClassMethods
          # 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