class ROstruct
Public Class Methods
new(options = {})
click to toggle source
# File lib/rostruct.rb, line 4 def initialize(options = {}) @as_hash = options.with_indifferent_access options.each do |key, value| if value.is_a?(Hash) value = ROstruct.new(value) end send("#{key}=", value) end end
Public Instance Methods
to_h()
click to toggle source
# File lib/rostruct.rb, line 16 def to_h @as_hash end
Private Instance Methods
eigenclass()
click to toggle source
# File lib/rostruct.rb, line 26 def eigenclass class << self self end end
method_missing(method_name, *args, &block)
click to toggle source
# File lib/rostruct.rb, line 32 def method_missing(method_name, *args, &block) if method_name.to_s.include?("=") method_name = method_name.to_s.gsub(/\=/) {} eigenclass.send :define_method, method_name do instance_variable_get("@#{method_name}") end eigenclass.send :define_method, "#{method_name}=" do |value| instance_variable_set("@#{method_name}", value) end send("#{method_name}=", *args, &block) else nil end end
respond_to_missing?(method_name, include_private = false)
click to toggle source
Calls superclass method
# File lib/rostruct.rb, line 22 def respond_to_missing?(method_name, include_private = false) method_name.to_s.include?("=") || super end