Class: Descriptor::Builder

Inherits:
Object show all
Defined in:
lib/rui/descriptor.rb

Instance Method Summary collapse

Constructor Details

#initialize(desc) ⇒ Builder

Returns a new instance of Builder.



216
217
218
# File 'lib/rui/descriptor.rb', line 216

def initialize(desc)
  @__desc__ = desc
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &blk) ⇒ Object



220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
# File 'lib/rui/descriptor.rb', line 220

def method_missing(name, *args, &blk)
  opts = if args.empty?
    { }
  elsif args.size == 1
    if args.first.is_a? Hash
      args.first
    else
      { :name => args.first }
    end
  else
    args[-1].merge(:name => args.first)
  end
  child = Descriptor.new(name, opts)
  self.class.new(child).instance_eval(&blk) if block_given?
  __desc__.add_child(child)
end

Instance Method Details

#merge_point(count = -1)) ⇒ Object



237
238
239
# File 'lib/rui/descriptor.rb', line 237

def merge_point(count = -1)
  @__desc__.add_merge_point(@__desc__.children.size, count)
end