Class: Kamaze::Project::Struct

Inherits:
OpenStruct
  • Object
show all
Defined in:
lib/kamaze/project/struct.rb

Overview

Generic struct (alaOpenStruct)

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args) ⇒ Object

Introduces some strictness on OpenStruct#method_missing

Returns:

Raises:

  • (NoMethodError)

See Also:



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/kamaze/project/struct.rb', line 19

def method_missing(method, *args)
  if method[-1] != '='
    unless self.to_h.include?(method.to_sym)
      message = "undefined method `#{method}' for #{self}"

      raise NoMethodError, message, caller(1)
    end
  end

  super
end

Instance Method Details

#respond_to_missing?(method, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/kamaze/project/struct.rb', line 31

def respond_to_missing?(method, include_private = false)
  super
end