class BBLib::HashStruct

Protected Instance Methods

method_missing(method, *args, &block) click to toggle source
Calls superclass method
# File lib/bblib/core/classes/hash_struct.rb, line 8
def method_missing(method, *args, &block)
  if args.empty? && ![:to_ary].include?(method)
    if method.to_s.end_with?('?')
      define_singleton_method(method) do
        self[method[0..-2].to_sym] ? true : false
      end
      send(method)
    else
      define_singleton_method(method) do
        self[method]
      end
      self[method]
    end
  elsif method.to_s.end_with?('=')
    define_singleton_method(method) do |arg|
      self[method[0..-2].to_sym] = arg
    end
    self[method[0..-2].to_sym] = args.first
  else
    super
  end
end
respond_to_missing?(method, include_private = false) click to toggle source
Calls superclass method
# File lib/bblib/core/classes/hash_struct.rb, line 31
def respond_to_missing?(method, include_private = false)
  include?(method) || method.to_s =~ /\?|\=/ && include?(method.to_s[0..-2].to_sym) || super
end