Module: Gitlab::GitalyClient::AttributesBag

Extended by:
ActiveSupport::Concern
Included in:
Diff, WikiFile, WikiPage
Defined in:
lib/gitlab/gitaly_client/attributes_bag.rb

Overview

This module expects an `ATTRS` const to be defined on the subclass See GitalyClient::WikiFile for an example

Instance Method Summary collapse

Instance Method Details

#==(other) ⇒ Object


22
23
24
25
26
# File 'lib/gitlab/gitaly_client/attributes_bag.rb', line 22

def ==(other)
  attributes.all? do |field|
    instance_variable_get("@#{field}") == other.instance_variable_get("@#{field}")
  end
end

#attributesObject


28
29
30
# File 'lib/gitlab/gitaly_client/attributes_bag.rb', line 28

def attributes
  self.class.const_get(:ATTRS, false)
end

#initialize(params) ⇒ Object


14
15
16
17
18
19
20
# File 'lib/gitlab/gitaly_client/attributes_bag.rb', line 14

def initialize(params)
  params = params.with_indifferent_access

  attributes.each do |attr|
    instance_variable_set("@#{attr}", params[attr])
  end
end