debian-mirror-gitlab/lib/gitlab/github_import/representation/expose_attribute.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

31 lines
665 B
Ruby
Raw Permalink Normal View History

2018-03-17 18:26:18 +05:30
# frozen_string_literal: true
module Gitlab
module GithubImport
module Representation
module ExposeAttribute
extend ActiveSupport::Concern
2018-11-20 20:47:30 +05:30
class_methods do
2018-03-17 18:26:18 +05:30
# 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
2022-10-11 01:57:18 +05:30
def [](key)
respond_to?(key.to_sym) ? attributes[key] : nil
end
2018-03-17 18:26:18 +05:30
end
end
end
end