Class: Attrio::Builders::ReaderBuilder

Inherits:
AccessorBuilder show all
Defined in:
lib/attrio/builders/reader_builder.rb

Class Method Summary collapse

Methods inherited from AccessorBuilder

define, define_aliases

Class Method Details

.accessorObject



8
9
10
# File 'lib/attrio/builders/reader_builder.rb', line 8

def self.accessor
  :reader
end

.define_accessor(klass, type, options) ⇒ Object



12
13
14
15
16
17
18
19
20
# File 'lib/attrio/builders/reader_builder.rb', line 12

def self.define_accessor(klass, type, options)
  unless klass.method_defined?(options[:method_name])
    klass.send :define_method, options[:method_name] do
      self.instance_variable_get(options[:instance_variable_name])
    end

    klass.send options[:method_visibility], options[:method_name]
  end
end