Module: Mirage::Helpers::MethodBuilder

Included in:
Template::Configuration, Template::Model::CommonMethods, Template::Model::InstanceMethods
Defined in:
lib/mirage/client/helpers/method_builder.rb

Instance Method Summary collapse

Instance Method Details

#builder_methods(*method_names) ⇒ Object Also known as: builder_method



4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/mirage/client/helpers/method_builder.rb', line 4

def builder_methods *method_names

  defaulted = Object.new

  method_names.each do |method_name|
    method_name = method_name.to_sym
    define_method method_name do |arg = defaulted|
      return instance_variable_get("@#{method_name}".to_sym) if arg == defaulted
      instance_variable_set("@#{method_name}".to_sym, arg)
      self
    end
  end

end