Class: ROstruct
- Inherits:
-
Object
- Object
- ROstruct
- Defined in:
- lib/rostruct.rb
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ ROstruct
constructor
A new instance of ROstruct.
- #to_h ⇒ Object
Constructor Details
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object (private)
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# 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 |
Instance Method Details
#to_h ⇒ Object
16 17 18 |
# File 'lib/rostruct.rb', line 16 def to_h @as_hash end |