Skip to Content Skip to Search
Methods
#
B
E
N
R

Class Public methods

batch(owner, path, line)

# File activemodel/lib/active_model/attribute_methods.rb, line 340
def batch(owner, path, line)
  if owner.is_a?(CodeGenerator)
    yield owner
  else
    instance = new(owner, path, line)
    result = yield instance
    instance.execute
    result
  end
end

new(owner, path, line)

# File activemodel/lib/active_model/attribute_methods.rb, line 352
def initialize(owner, path, line)
  @owner = owner
  @path = path
  @line = line
  @sources = ["# frozen_string_literal: true\n"]
  @renames = {}
end

Instance Public methods

<<(source_line)

# File activemodel/lib/active_model/attribute_methods.rb, line 360
def <<(source_line)
  @sources << source_line
end

execute()

# File activemodel/lib/active_model/attribute_methods.rb, line 368
def execute
  @owner.module_eval(@sources.join(";"), @path, @line - 1)
  @renames.each do |old_name, new_name|
    @owner.alias_method new_name, old_name
    @owner.undef_method old_name
  end
end

rename_method(old_name, new_name)

# File activemodel/lib/active_model/attribute_methods.rb, line 364
def rename_method(old_name, new_name)
  @renames[old_name] = new_name
end