module Marta::Dialogs

All many-steps dialogs should be here

There is at least one situation when getting info from user is not so simple We need dialogs for cases like that. Now there is only dialog about method

Private Instance Methods

dynamise(variable_name, what) click to toggle source

Massive gsub for attribute

# File lib/marta/dialogs.rb, line 193
def dynamise(variable_name, what)
  what.each do |entry|
    entry.each do |value|
      value.gsub!(self.instance_variable_get("@#{variable_name}"),
         '#{@' + variable_name + '}')
    end
  end
end
dynamise_method(vars, method) click to toggle source

Marta will search for page variables in attributes of element in order to create dynamic element by itself. It must be splited. And moved.

# File lib/marta/dialogs.rb, line 204
def dynamise_method(vars, method)
  vars.each_pair do |variable_name, variable|
    if variable_name.include?('text')
      dynamise variable_name, [method['positive']['self']['text'],
                               method['positive']['pappy']['text'],
                               method['positive']['granny']['text'],
                               method['negative']['self']['text'],
                               method['negative']['pappy']['text'],
                               method['negative']['granny']['text']]
    else
      [method['positive'], method['negative']].each do |method|
        method.each_pair do |level, content|
          content['attributes'].each_pair do |attribute_name, values|
            if variable_name.include?(attribute_name)
              dynamise variable_name, [values]
            end
          end
        end
      end
    end
  end
  method
end
user_method_dialogs(method_name) click to toggle source

Method definition process

# File lib/marta/dialogs.rb, line 183
def user_method_dialogs(method_name)
  dialog_master = MethodSpeaker.new(method_name, self)
  data = dialog_master.dialog
  data['meths'][method_name] =
                dynamise_method(data['vars'], data['meths'][method_name])
  file_write(self.class_name.to_s, data)
  data
end