Module: Paperclip::Ext::Class

Defined in:
lib/dm-paperclip/ext/class.rb

Defined Under Namespace

Modules: Hook

Class Method Summary collapse

Class Method Details

.inheritable_attributes(klass) ⇒ Object



3
4
5
6
7
8
# File 'lib/dm-paperclip/ext/class.rb', line 3

def self.inheritable_attributes(klass)
  unless klass.instance_variable_defined?(IVar)
    klass.instance_variable_set(IVar, EMPTY_INHERITABLE_ATTRIBUTES)
  end
  klass.instance_variable_get(IVar)
end

.read_inheritable_attribute(klass, key) ⇒ Object



17
18
19
# File 'lib/dm-paperclip/ext/class.rb', line 17

def self.read_inheritable_attribute(klass, key)
  inheritable_attributes(klass)[key]
end

.reset_inheritable_attributes(klass) ⇒ Object



21
22
23
# File 'lib/dm-paperclip/ext/class.rb', line 21

def self.reset_inheritable_attributes(klass)
  klass.instance_variable_set(IVar, EMPTY_INHERITABLE_ATTRIBUTES)
end

.write_inheritable_attribute(klass, key, value) ⇒ Object



10
11
12
13
14
15
# File 'lib/dm-paperclip/ext/class.rb', line 10

def self.write_inheritable_attribute(klass, key, value)
  if inheritable_attributes(klass).equal?(EMPTY_INHERITABLE_ATTRIBUTES)
    klass.instance_variable_set(IVar, {})
  end
  inheritable_attributes(klass)[key] = value
end