Method: TinkitBaseNode#initialize
- Defined in:
- lib/tinkit_base_node.rb
#initialize(init_params = {}) ⇒ TinkitBaseNode
Normal instantiation can take two forms that differ only in the source for the initial parameters. The constructor could be called by the user and passed only user data, or the constructor could be called by a class collection method and the initial parameters would come from a datastore. In the latter case, some of the parameters will include information about the datastore (model metadata).
345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 |
# File 'lib/tinkit_base_node.rb', line 345 def initialize(init_params = {}) #setting the class accessor to also be an instance accessor #for convenience and hopefully doesn't create confusion @my_GlueEnv = self.class.myGlueEnv @@log.debug {"initializing with: #{init_params.inspect}"} if @@log.debug? raise "init_params cannot be nil" unless init_params @saved_to_model = nil #TODO rename to sychronized_to_model #make sure keys are symbols init_params = HashKeys.str_to_sym(init_params) @_user_data, @_model_metadata = filter_user_from_model_data(init_params) @@log.debug {"data filtered into user data: #{@_user_data}"} if @@log.debug? @@log.debug {"data filtered into model metadata: #{@_model_metadata}"} if @@log.debug? instance_data_validations(@_user_data) node_key = get__user_data_id(@_user_data) moab_file_mgr = @my_GlueEnv._files_mgr_class.new(@my_GlueEnv, node_key) @_files_mgr = FilesMgr.new(moab_file_mgr) @_model_metadata = (@_model_metadata, node_key) @@log.debug {"Updated model metadata: #{@_model_metadata.inspect}"} if @@log.debug? init_params.each do |attr_name, attr_value| __set_userdata_key(attr_name.to_sym, attr_value) end end |