class Granite::Represents::Reflection

Public Class Methods

attribute_class() click to toggle source
# File lib/granite/represents/reflection.rb, line 18
def attribute_class
  @attribute_class ||= Granite::Represents::Attribute
end
build(target, generated_methods, name, *args, &block) click to toggle source
Calls superclass method
# File lib/granite/represents/reflection.rb, line 7
def build(target, generated_methods, name, *args, &block)
  options = args.last

  reference = target.reflect_on_association(options[:of]) if target.respond_to?(:reflect_on_association)
  reference ||= target.reflect_on_attribute(options[:of]) if target.respond_to?(:reflect_on_attribute)

  target.validates_presence_of(reference.name) if reference

  super(target, generated_methods, name, *args, &block)
end