Class: Syskit::Models::DataServiceModel::BlockInstanciator

Inherits:
BasicObject
Defined in:
lib/syskit/models/data_service.rb

Overview

Internal class used to apply configuration blocks to data services. I.e. when one does

data_service_type 'Type' do
  input_port ...
end

The given block is applied on an instance of BlockInstanciator that forwards the calls to, in order of preference, the interface and then the service

One should not use BlockInstanciator directly. Use DataServiceModel#apply_block

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(model, name = nil) ⇒ BlockInstanciator

Returns a new instance of BlockInstanciator



99
100
101
102
103
104
105
106
107
# File 'lib/syskit/models/data_service.rb', line 99

def initialize(model, name = nil)
    @model = model
    @name = name || model.name
    @orogen_model = model.orogen_model

    if !@orogen_model
        raise InternalError, "no interface for #{model.short_name}"
    end
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(m, *args, &block) ⇒ Object



114
115
116
117
118
119
# File 'lib/syskit/models/data_service.rb', line 114

def method_missing(m, *args, &block)
    if @orogen_model.respond_to?(m)
        @orogen_model.public_send(m, *args, &block)
    else @model.public_send(m, *args, &block)
    end
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name



98
99
100
# File 'lib/syskit/models/data_service.rb', line 98

def name
  @name
end

Instance Method Details

#respond_to_missing?(m, include_private) ⇒ Boolean

Returns:

  • (Boolean)


109
110
111
112
# File 'lib/syskit/models/data_service.rb', line 109

def respond_to_missing?(m, include_private)
    @orogen_model.respond_to?(m) ||
        @model.respond_to?(m)
end