Class: Reactor::Plans::CreateAttribute

Inherits:
CommonAttribute show all
Defined in:
lib/reactor/plans/create_attribute.rb

Constant Summary

Constants inherited from CommonAttribute

Reactor::Plans::CommonAttribute::ALLOWED_PARAMS

Instance Method Summary collapse

Methods inherited from CommonAttribute

#set

Methods included from Prepared

#error, #separate_arguments

Constructor Details

#initialize(*args) ⇒ CreateAttribute

Returns a new instance of CreateAttribute.



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/reactor/plans/create_attribute.rb', line 7

def initialize(*args)
  super()
  (name, type), options = separate_arguments(*args)
  @name = name || options[:name]
  @type = type || options[:type]
  # Default values for attributes:
  # isSearchableInCM: false
  # isSearchableInTE: false
  set(:isSearchableInCM, 0)
  set(:isSearchableInTE, 0)
end

Instance Method Details

#migrate!Object



26
27
28
29
# File 'lib/reactor/plans/create_attribute.rb', line 26

def migrate!
  attrib = Reactor::Cm::Attribute.create(@name, @type)
  migrate_params!(attrib)
end

#prepare!Object



19
20
21
22
23
24
# File 'lib/reactor/plans/create_attribute.rb', line 19

def prepare!
  error("name ist nil") if @name.nil?
  error("type is nil") if @type.nil?
  # TODO: Type check
  prepare_params!(nil)
end