Module: StrongType::ClassMethods
- Defined in:
- lib/strong_ruby/strong_type.rb
Instance Method Summary collapse
Instance Method Details
#inherited(base) ⇒ Object
32 33 34 35 36 |
# File 'lib/strong_ruby/strong_type.rb', line 32 def inherited(base) if @__method_types base.instance_variable_set(:@__method_types, @__method_types.dup) end end |
#method_added(method_name) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/strong_ruby/strong_type.rb', line 14 def method_added(method_name) super return if __safe_method_definition? || !__unassigned_method_types __safe_method_definition! do __set_method_types method_name, __unassigned_method_types original_method = instance_method(method_name) define_method(method_name) do |*attrs, &block| self.class.send(:__check_method_types, method_name, *attrs) return original_method.bind(self).(*attrs, &block) end end __set_unassigned_method_types(nil) method_name end |
#Type(*attrs) ⇒ Object
10 11 12 |
# File 'lib/strong_ruby/strong_type.rb', line 10 def Type(*attrs) __set_unassigned_method_types MethodTypes.new(*attrs) end |