Class: Gizzard::Transformation::Op::CreateShard

Inherits:
ShardOp show all
Defined in:
lib/gizzard/transformation_op.rb

Instance Attribute Summary

Attributes inherited from ShardOp

#template

Instance Method Summary collapse

Methods inherited from ShardOp

#eql?, #initialize, #inverse?

Methods inherited from BaseOp

#<=>, #eql?, #inspect, #inverse?, #involved_shards

Constructor Details

This class inherits a constructor from Gizzard::Transformation::Op::ShardOp

Instance Method Details

#apply(nameserver, table_id, base_id, table_prefix, translations) ⇒ Object



176
177
178
# File 'lib/gizzard/transformation_op.rb', line 176

def apply(nameserver, table_id, base_id, table_prefix, translations)
  nameserver.create_shard(template.to_shard_info(table_prefix, translations))
end

#expand(copy_source, involved_in_copy) ⇒ Object



162
163
164
165
166
167
168
169
170
171
172
173
174
# File 'lib/gizzard/transformation_op.rb', line 162

def expand(copy_source, involved_in_copy)
  if involved_in_copy && @wrapper_type
    wrapper = ShardTemplate.new(@wrapper_type, template.host, template.weight, '', '', [template])
    { :prepare => [self, CreateShard.new(wrapper), AddLink.new(wrapper, template)],
      :cleanup => [RemoveLink.new(wrapper, template), DeleteShard.new(wrapper)],
      :copy => [CopyShard.new(copy_source, template)] }
  elsif involved_in_copy
    { :prepare => [self],
      :copy => [CopyShard.new(copy_source, template)] }
  else
    { :prepare => [self] }
  end
end