module Finest::Struct

Finest Struct

Public Class Methods

new(json = {}, keys = []) click to toggle source
# File lib/finest/builder.rb, line 100
def initialize(json = {}, keys = [])
  accessor_builder('to_h', {})
  json.each do |k, v|
    send("#{k}=", v)
  end
end

Public Instance Methods

method_missing(name, *args) click to toggle source
# File lib/finest/builder.rb, line 107
def method_missing(name, *args)
  attribute = name.to_s.start_with?(/\d/) ? "_#{name.to_s}" : name.to_s
  if attribute =~ /=$/
    @to_h[attribute.chop] =
      if args[0].respond_to?(:key?) || args[0].is_a?(Hash)
        self.class.new(args[0])
      else
        args[0]
      end
  else
    @to_h[attribute]
  end
end
respond_to_missing?() click to toggle source
# File lib/finest/builder.rb, line 121
def respond_to_missing?; end