class Origen::SubBlocks::Placeholder
Attributes
attributes[R]
name[R]
owner[R]
Public Class Methods
new(owner, name, attributes)
click to toggle source
# File lib/origen/sub_blocks.rb, line 469 def initialize(owner, name, attributes) @owner = owner @name = name @attributes = attributes end
Public Instance Methods
==(obj)
click to toggle source
# File lib/origen/sub_blocks.rb, line 523 def ==(obj) if obj.is_a?(Placeholder) materialize == obj.materialize else materialize == obj end end
Also aliased as: equal?
add_attributes(attrs)
click to toggle source
# File lib/origen/sub_blocks.rb, line 475 def add_attributes(attrs) @attributes = @attributes.merge(attrs) end
class()
click to toggle source
Make this appear like a sub-block to any application code
# File lib/origen/sub_blocks.rb, line 480 def class klass end
clone()
click to toggle source
# File lib/origen/sub_blocks.rb, line 536 def clone materialize.clone end
dup()
click to toggle source
# File lib/origen/sub_blocks.rb, line 540 def dup materialize.dup end
freeze()
click to toggle source
# File lib/origen/sub_blocks.rb, line 532 def freeze materialize.freeze end
inspect()
click to toggle source
Make it look like a sub-block in the console to avoid confusion
# File lib/origen/sub_blocks.rb, line 496 def inspect "<SubBlock: #{name}>" end
is_a?(klass)
click to toggle source
Make this appear like a sub-block to any application code
# File lib/origen/sub_blocks.rb, line 485 def is_a?(klass) # Because sub_blocks are stored in a hash.with_indifferent_access, the value is tested # against being a Hash or Array when it is added to the hash. This prevents the class being # looking up and loaded by the autoload system straight away, especially if the sub-block # has been specified to lazy load return false if klass == Hash || klass == Array klass == self.klass || klass == Placeholder end
klass()
click to toggle source
# File lib/origen/sub_blocks.rb, line 548 def klass @klass ||= begin class_name = attributes.delete(:class_name) tmp_class = nil if class_name begin tmp_class = "::#{owner.namespace}::#{class_name}" klass = eval(tmp_class) rescue NameError => e raise if e.message !~ /^uninitialized constant (.*)$/ || tmp_class !~ /#{Regexp.last_match(1)}/ begin tmp_class = "::#{class_name}" klass = eval(tmp_class) rescue NameError => e raise if e.message !~ /^uninitialized constant (.*)$/ || tmp_class !~ /#{Regexp.last_match(1)}/ begin tmp_class = "#{owner.class}::#{class_name}" klass = eval(tmp_class) rescue NameError => e raise if e.message !~ /^uninitialized constant (.*)$/ || tmp_class !~ /#{Regexp.last_match(1)}/ puts "Could not find class: #{class_name}" raise 'Unknown sub block class!' end end end else klass = Origen::SubBlock end unless klass.respond_to?(:includes_origen_model) puts 'Any class which is to be instantiated as a sub_block must include Origen::Model,' puts "add this to #{klass}:" puts '' puts ' include Origen::Model' puts '' fail 'Sub block does not include Origen::Model!' end klass end end
materialize()
click to toggle source
# File lib/origen/sub_blocks.rb, line 508 def materialize block = nil file = attributes.delete(:file) load_block = attributes.delete(:load_block) dir = attributes.delete(:dir) || owner.send(:export_dir) block = owner.send(:instantiate_sub_block, name, klass, attributes) if file require File.join(dir, file) block.extend owner.send(:export_module_names_from_path, file).join('::').constantize end block.load_block(load_block) if load_block block.owner = owner block end
method_missing(method, *args, &block)
click to toggle source
# File lib/origen/sub_blocks.rb, line 500 def method_missing(method, *args, &block) materialize.send(method, *args, &block) end
respond_to?(method, include_private = false)
click to toggle source
# File lib/origen/sub_blocks.rb, line 504 def respond_to?(method, include_private = false) materialize.respond_to?(method, include_private) end
to_json(*args)
click to toggle source
# File lib/origen/sub_blocks.rb, line 544 def to_json(*args) materialize.to_json(*args) end