Class: Moon::Action::Reference

Inherits:
Object
  • Object
show all
Defined in:
lib/moon/action/reference.rb

Overview

The action creates a reference to the given store object and stores it in the given model attribute.

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Reference

Returns a new instance of Reference.



5
6
7
8
9
# File 'lib/moon/action/reference.rb', line 5

def initialize(options)
  from, to = options.values_at :from, :to
  @store_method, @store_key = from
  @model_key, @model_attribute = to
end

Instance Method Details

#perform(context) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/moon/action/reference.rb', line 11

def perform(context)
  @context = context
  fetch_object
  create_reference
  store_reference
  nil
end