Module: Granite::Action::Subject::ClassMethods

Defined in:
lib/granite/action/subject.rb

Instance Method Summary collapse

Instance Method Details

#subject(name, *args, &block) ⇒ Object



23
24
25
26
27
28
29
30
31
# File 'lib/granite/action/subject.rb', line 23

def subject(name, *args, &block)
  reflection = reflect_on_association(name)
  reflection ||= references_one name, *args, &block

  alias_association :subject, reflection.name
  alias_attribute :id, reflection.reference_key

  self._subject = name
end