class Superstore::Associations::HasOne

Public Instance Methods

reader() click to toggle source
# File lib/superstore/associations/has_one.rb, line 4
def reader
  unless loaded?
    self.target = load_target
  end

  target
end
writer(record) click to toggle source
# File lib/superstore/associations/has_one.rb, line 12
def writer(record)
  self.target = record
end

Private Instance Methods

load_target() click to toggle source
# File lib/superstore/associations/has_one.rb, line 18
def load_target
  association_class.where(reflection.foreign_key => owner.try(reflection.primary_key)).first
end