Module: Katello::LazyAccessor::InstanceMethods

Defined in:
app/lib/katello/lazy_accessor.rb

Instance Method Summary collapse

Instance Method Details

#changed_remote_attributesObject



67
68
69
# File 'app/lib/katello/lazy_accessor.rb', line 67

def changed_remote_attributes
  @changed_remote_attributes ||= {}
end

#changed_remote_attributes=(val) ⇒ Object



71
72
73
# File 'app/lib/katello/lazy_accessor.rb', line 71

def changed_remote_attributes=(val)
  @changed_remote_attributes = val
end

#lazy_attributesObject



98
99
100
101
102
# File 'app/lib/katello/lazy_accessor.rb', line 98

def lazy_attributes
  attrs = (self.class.superclass.respond_to? :lazy_attributes) ? self.class.superclass.lazy_attributes : []
  attrs += (self.class.lazy_attributes || [])
  attrs.uniq
end

#reloadObject



92
93
94
95
96
# File 'app/lib/katello/lazy_accessor.rb', line 92

def reload(*)
  super.tap do
    changed_remote_attributes.clear
  end
end

#remote_attribute_changed?(attr) ⇒ Boolean

Returns:

  • (Boolean)


75
76
77
# File 'app/lib/katello/lazy_accessor.rb', line 75

def remote_attribute_changed?(attr)
  changed_remote_attributes.key?(attr)
end

#saveObject



79
80
81
82
83
84
# File 'app/lib/katello/lazy_accessor.rb', line 79

def save(*)
  if status = super
    changed_remote_attributes.clear
  end
  status
end

#save!Object



86
87
88
89
90
# File 'app/lib/katello/lazy_accessor.rb', line 86

def save!(*)
  super.tap do
    changed_remote_attributes.clear
  end
end