Class: Attrio::Builders::AccessorBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/attrio/builders/accessor_builder.rb

Direct Known Subclasses

ReaderBuilder, WriterBuilder

Class Method Summary collapse

Class Method Details

.accessorObject

Raises:

  • (NotImplementedError)


6
7
8
# File 'lib/attrio/builders/accessor_builder.rb', line 6

def self.accessor
  raise NotImplementedError
end

.define(klass, type, options) ⇒ Object



10
11
12
13
# File 'lib/attrio/builders/accessor_builder.rb', line 10

def self.define(klass, type, options)
  self.define_accessor(klass, type, options)
  self.define_aliases(klass, type, options)
end

.define_aliases(klass, type, options) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/attrio/builders/accessor_builder.rb', line 15

def self.define_aliases(klass, type, options)
  if type.respond_to?("default_#{self.accessor.to_s}_aliases")
    type.send("default_#{self.accessor.to_s}_aliases", options[:method_name]).each do |alias_method_name|
      klass.send(:alias_method, alias_method_name, options[:method_name])
    end
  end
end