Class: Impressionist::SetupAssociation

Inherits:
Object
  • Object
show all
Defined in:
lib/impressionist/setup_association.rb

Overview

Impressionist::SetupAssociation.new(entity).set

Instance Method Summary collapse

Constructor Details

#initialize(receiver) ⇒ SetupAssociation

Returns a new instance of SetupAssociation.



4
5
6
# File 'lib/impressionist/setup_association.rb', line 4

def initialize(receiver)
  @receiver = receiver
end

Instance Method Details

#define_belongs_toObject



14
15
16
# File 'lib/impressionist/setup_association.rb', line 14

def define_belongs_to
  receiver.belongs_to(:impressionable, :polymorphic => true)
end

#include_attr_acc?Boolean

True or False Note toggle returns false if rails >= 4

Returns:

  • (Boolean)


10
11
12
# File 'lib/impressionist/setup_association.rb', line 10

def include_attr_acc?
  toggle && make_accessible
end

#setObject



18
19
20
21
# File 'lib/impressionist/setup_association.rb', line 18

def set
  define_belongs_to
  include_attr_acc?
end