Class: IndifferentAccessOpenStruct
- Defined in:
- lib/githooks/core_ext/ostruct.rb
Instance Method Summary collapse
Instance Method Details
#[](k) ⇒ Object
33 34 35 |
# File 'lib/githooks/core_ext/ostruct.rb', line 33 def [](k) public_send(k) end |
#[]=(k, v) ⇒ Object
37 38 39 |
# File 'lib/githooks/core_ext/ostruct.rb', line 37 def []=(k, v) public_send("#{k}=", v) end |
#new_ostruct_member(name) ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/githooks/core_ext/ostruct.rb', line 23 def new_ostruct_member(name) return super unless name.to_s.include? '-' original_name, sanitized_name = name, name.to_s.gsub('-', '_').to_sym return if respond_to?(sanitized_name) define_singleton_method(sanitized_name) { @table[original_name] } define_singleton_method("#{sanitized_name}=") { |x| @table[original_name] = x } end |
#to_h ⇒ Object
41 42 43 |
# File 'lib/githooks/core_ext/ostruct.rb', line 41 def to_h Thor::CoreExt::HashWithIndifferentAccess.new(@table) end |