Class: Ostructer::OsBase

Inherits:
Object show all
Defined in:
lib/ostructer.rb

Overview

NB: key.first -> different with Rails or without (without results in more than one letter!!)

Direct Known Subclasses

OsArray, OsOpenStruct, OsOpenStructNil, OsValue

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#fieldObject

read,write



34
35
36
# File 'lib/ostructer.rb', line 34

def field
  @field
end

#loggerObject (readonly)

base for OsArray/OsOpenStruct/OsOpenStructNil



32
33
34
# File 'lib/ostructer.rb', line 32

def logger
  @logger
end

#parentObject

read,write



33
34
35
# File 'lib/ostructer.rb', line 33

def parent
  @parent
end

Instance Method Details

#full_dot_pathObject



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/ostructer.rb', line 36

def full_dot_path
  path = "#{@field}"
  node = @parent

  ## NOTE: assume if parent == nil openstruct is root node    
  while node && node.parent
    # logger.debug "node.class: #{node.class}, node.field: #{node.field}"  
    if node.is_a?( OsArray )
      path = "#{node.field}" + path
    else
      path = "#{node.field}." + path
    end
    node = node.parent      
  end
  path
end