Class: MongodbLogger::ServerModel::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/mongodb_logger/server/model/base.rb

Direct Known Subclasses

AdditionalFilter, Analytic, Filter

Instance Method Summary collapse

Instance Method Details

#create_variable(k, v) ⇒ Object



13
14
15
16
17
# File 'lib/mongodb_logger/server/model/base.rb', line 13

def create_variable(k, v)
  self.instance_variable_set("@#{k}", v)  ##  create instance variable
  self.class.send(:define_method, k, proc{self.instance_variable_get("@#{k}")})  ## method to return instance variable
  self.class.send(:define_method, "#{k}=", proc{|v| self.instance_variable_set("@#{k}", v)})  ## method to set instance variable
end

#set_params_to_methodsObject



7
8
9
10
11
# File 'lib/mongodb_logger/server/model/base.rb', line 7

def set_params_to_methods
  @params.each do |k,v|
    self.send("#{k}=", v) if self.respond_to?(k) && v && !v.blank?
  end unless @params.blank?
end