Module: Granite::AssignData::ClassMethods

Defined in:
lib/granite/assign_data.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#assign_data(*methods, **options, &block) ⇒ Object

Defines a callback to call when assigning data from business action to model.

Parameters:

  • methods (Array<Symbol>)

    list of methods to call

  • block (Proc)

    a block to call

  • options (Hash)

    a customizable set of options

Options Hash (**options):

  • :if (Symbol, Proc, Object)

    call methods/block if this condition evaluates to true

  • :unless (Symbol, Proc, Object)

    call method/block unless this condition evaluates to true



23
24
25
26
# File 'lib/granite/assign_data.rb', line 23

def assign_data(*methods, **options, &block)
  self.data_assignments += methods.map { |method| DataAssignment.new(method, options) }
  self.data_assignments += [DataAssignment.new(block, options)] if block
end