Class: ObjectiveCommand::Datas::Factory

Inherits:
ObjectiveCommand::Datas.selfself::Data
  • Object
show all
Defined in:
lib/objective_command/datas/factory.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(values = {}, *a, &b) ⇒ Factory

Returns a new instance of Factory.



14
15
16
17
18
19
20
# File 'lib/objective_command/datas/factory.rb', line 14

def initialize ( values={}, *a, &b )
  super(*a, &b)
  values.each do |k, v|
    send("#{k}=", v)
  end
  @command_data_class ||= Temp
end

Instance Attribute Details

#command_data_classObject

Returns the value of attribute command_data_class.



12
13
14
# File 'lib/objective_command/datas/factory.rb', line 12

def command_data_class
  @command_data_class
end

Instance Method Details

#create(*a, &b) ⇒ Object



33
34
35
# File 'lib/objective_command/datas/factory.rb', line 33

def create ( *a, &b )
  new_command_data(*a, &b)
end

#new_command_data(*a, &b) ⇒ Object



22
23
24
25
26
27
28
29
30
31
# File 'lib/objective_command/datas/factory.rb', line 22

def new_command_data ( *a, &b )
  data = @command_data_class.new(*a, &b)
  instance_variables.each do |var|
    next if var == '@command_data_class'
    next if var =~ /^@__/
    val = instance_variable_get(var)
    data.send(var[1..-1] + '=', val) unless val.nil?
  end
  data
end