Module: TrackAttributes

Included in:
Backend
Defined in:
app/helpers/track_attributes.rb

Overview

Tracks accessor definitions on classes.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(klass) ⇒ Object


15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'app/helpers/track_attributes.rb', line 15

def self.extended(klass)
  klass.send :define_singleton_method, :attr_reader, ->(*params) do
    @attr_readers ||= []
    @attr_readers.concat params
    super(*params)
  end

  klass.send :define_singleton_method, :attr_writer, ->(*params) do
    @attr_writers ||= []
    @attr_writers.concat params
    super(*params)
  end

  klass.send :define_singleton_method, :attr_accessor, ->(*params) do
    @attr_accessors ||= []
    @attr_accessors.concat params
    super(*params)
  end
end

Instance Method Details

#attr_accessorsObject


11
12
13
# File 'app/helpers/track_attributes.rb', line 11

def attr_accessors
  self.instance_variable_get('@attr_accessors') || []
end

#attr_readersObject


3
4
5
# File 'app/helpers/track_attributes.rb', line 3

def attr_readers
  self.instance_variable_get('@attr_readers') || []
end

#attr_writersObject


7
8
9
# File 'app/helpers/track_attributes.rb', line 7

def attr_writers
  self.instance_variable_get('@attr_writers') || []
end