class EacRubyUtils::Struct

def [](key)

def [](key)
  key, bool = parse_key(key)
  bool ? self[key].present? : data[key]
end

def fetch(key)

def fetch(key)
  key, bool = parse_key(key)
  bool ? fetch(key).present? : data.fetch(key)
end

def initialize(initial_data = {})

def initialize(initial_data = {})
  self.data = initial_data.symbolize_keys
end

def merge(other)

def merge(other)
  other = self.class.new(other) unless other.is_a?(self.class)
  self.class.new(to_h.merge(other.to_h))
end

def method_missing(method_name, *arguments, &block)

def method_missing(method_name, *arguments, &block)
  property_method?(method_name) ? fetch(method_name) : super
end

def parse_key(key)

def parse_key(key)
  m = /\A(.+)\?\z/.match(key.to_s)
  [(m ? m[1] : key.to_s).to_sym, m ? true : false]
end

def property_method?(key)

def property_method?(key)
  property_methods.include?(key.to_sym)
end

def property_methods

def property_methods
  data.keys.flat_map { |k| [k.to_sym, :"#{k}?"] }
end

def respond_to_missing?(method_name, include_private = false)

def respond_to_missing?(method_name, include_private = false)
  property_method?(method_name) || super
end

def slice_fetch(*keys)

def slice_fetch(*keys)
  self.class.new(keys.index_with { |key| fetch(key) })
end

def to_h

def to_h
  data.dup
end