Class: Granite::Represents::Reflection
- Inherits:
-
Form::Model::Attributes::Reflections::Represents
- Object
- Form::Model::Attributes::Reflections::Represents
- Granite::Represents::Reflection
- Defined in:
- lib/granite/represents/reflection.rb
Class Method Summary collapse
Class Method Details
.attribute_class ⇒ Object
18 19 20 |
# File 'lib/granite/represents/reflection.rb', line 18 def attribute_class @attribute_class ||= Granite::Represents::Attribute end |
.build(target, generated_methods, name, *args, &block) ⇒ Object
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/granite/represents/reflection.rb', line 7 def build(target, generated_methods, name, *args, &block) = args.last reference = target.reflect_on_association([:of]) if target.respond_to?(:reflect_on_association) reference ||= target.reflect_on_attribute([:of]) if target.respond_to?(:reflect_on_attribute) target.validates_presence_of(reference.name) if reference super(target, generated_methods, name, *args, &block) end |