r_kit 0.5 → 1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. checksums.yaml +4 -4
  2. data/lib/r_kit/active_record_utility/active_record_extend.rb +28 -12
  3. data/lib/r_kit/active_record_utility/utilities/series.rb +115 -77
  4. data/lib/r_kit/active_record_utility/utilities/tag.rb +6 -2
  5. data/lib/r_kit/active_record_utility.rb +2 -0
  6. data/lib/r_kit/core/loader.rb +1 -1
  7. data/lib/r_kit/css/lib/assets/stylesheets/r_kit/base/typography/hr.scss +5 -0
  8. data/lib/r_kit/css/lib/assets/stylesheets/r_kit/base/typography/links.scss +2 -0
  9. data/lib/r_kit/css/lib/assets/stylesheets/r_kit/base/typography/paragraphs.scss +3 -1
  10. data/lib/r_kit/css/lib/assets/stylesheets/r_kit/base/typography/titles.scss +4 -2
  11. data/lib/r_kit/css/lib/assets/stylesheets/r_kit/base/typography.scss +1 -0
  12. data/lib/r_kit/css/lib/assets/stylesheets/r_kit/components/btn.scss +3 -0
  13. data/lib/r_kit/css/lib/assets/stylesheets/r_kit/mixins/alignments.scss +7 -0
  14. data/lib/r_kit/css/lib/assets/stylesheets/r_kit/mixins/blocks.scss +4 -0
  15. data/lib/r_kit/css/lib/assets/stylesheets/r_kit/mixins/box-shadows/curved-shadows.scss +1 -1
  16. data/lib/r_kit/css/lib/assets/stylesheets/r_kit/mixins/box-shadows/straight-shadows.scss +1 -1
  17. data/lib/r_kit/css/lib/assets/stylesheets/r_kit/mixins/links.scss +12 -0
  18. data/lib/r_kit/css/lib/assets/stylesheets/r_kit/mixins/titles.scss +6 -10
  19. data/lib/r_kit/css/lib/assets/stylesheets/r_kit/mixins.scss +2 -0
  20. data/lib/r_kit/css/lib/assets/stylesheets/r_kit/variables/colors.scss +1 -1
  21. data/lib/r_kit/css/sass_extend.rb +1 -2
  22. data/lib/r_kit/css.rb +13 -11
  23. data/lib/r_kit/decoration/action_view_base_extend.rb +1 -2
  24. data/lib/r_kit/decoration/base/collection.rb +11 -11
  25. data/lib/r_kit/decoration/base/object.rb +0 -18
  26. data/lib/r_kit/decoration/base.rb +39 -2
  27. data/lib/r_kit/decoration/class.rb +26 -55
  28. data/lib/r_kit/decoration/dsl.rb +14 -83
  29. data/lib/r_kit/decoration/enumerable_extend.rb +5 -1
  30. data/lib/r_kit/decoration/object_extend.rb +5 -0
  31. data/lib/r_kit/decoration.rb +4 -7
  32. data/lib/r_kit/dsl/base/thrust.rb +6 -2
  33. data/lib/r_kit/dsl/base.rb +9 -3
  34. data/lib/r_kit/dsl/dsl_extend.rb +1 -1
  35. data/lib/r_kit/dsl/test.rb +81 -0
  36. data/lib/r_kit/dsl.rb +1 -6
  37. data/lib/r_kit/frame/collection_dsl.rb +24 -0
  38. data/lib/r_kit/frame/empty_frame.rb +7 -0
  39. data/lib/r_kit/frame/instance_dsl.rb +30 -0
  40. data/lib/r_kit/frame.rb +14 -0
  41. data/lib/r_kit/grid/base/grid.rb +69 -19
  42. data/lib/r_kit/grid/base/grid_col.rb +22 -19
  43. data/lib/r_kit/grid/base.rb +1 -15
  44. data/lib/r_kit/grid/binding.rb +3 -10
  45. data/lib/r_kit/grid/lib/assets/stylesheets/r_kit/base/grid.scss +15 -18
  46. data/lib/r_kit/grid/lib/assets/stylesheets/r_kit/base/grid_flex.scss +19 -0
  47. data/lib/r_kit/grid/lib/assets/stylesheets/r_kit/base/grid_items.scss +5 -0
  48. data/lib/r_kit/grid/lib/assets/stylesheets/r_kit/grid.scss +2 -0
  49. data/lib/r_kit/grid/lib/assets/stylesheets/r_kit/mixins/{gris.scss → grid.scss} +0 -0
  50. data/lib/r_kit/grid.rb +2 -3
  51. data/lib/r_kit/override/base.rb +125 -0
  52. data/lib/r_kit/override/method_extend.rb +8 -0
  53. data/lib/r_kit/override/module_extend.rb +53 -0
  54. data/lib/r_kit/override/pattern.rb +53 -0
  55. data/lib/r_kit/override/perfs.rb +117 -0
  56. data/lib/r_kit/override/test.rb +466 -0
  57. data/lib/r_kit/override/unbound_method_extend.rb +8 -0
  58. data/lib/r_kit/override.rb +15 -0
  59. data/lib/r_kit/pagination/base/page.rb +5 -23
  60. data/lib/r_kit/pagination/base.rb +32 -62
  61. data/lib/r_kit/pagination/dsl.rb +10 -0
  62. data/lib/r_kit/pagination/enumerable_extend.rb +7 -0
  63. data/lib/r_kit/pagination.rb +29 -2
  64. data/lib/r_kit/parser/base.rb +19 -0
  65. data/lib/r_kit/parser/leaf.rb +72 -0
  66. data/lib/r_kit/parser/test.rb +76 -0
  67. data/lib/r_kit/parser/tree.rb +22 -0
  68. data/lib/r_kit/parser.rb +8 -0
  69. data/lib/r_kit/struct/collection_delegator.rb +0 -6
  70. data/lib/r_kit/utility/basic_object_extend.rb +9 -0
  71. data/lib/r_kit/utility/kernel_extend.rb +9 -3
  72. data/lib/r_kit/utility/main_extend.rb +22 -0
  73. data/lib/r_kit/utility/module_extend.rb +18 -11
  74. data/lib/r_kit/utility/simple_delegator_extend.rb +1 -1
  75. data/lib/r_kit/utility/symbol_extend.rb +1 -1
  76. data/lib/r_kit/utility.rb +4 -2
  77. data/lib/r_kit/version.rb +1 -1
  78. metadata +29 -5
  79. data/lib/r_kit/grid/base/grid_row.rb +0 -29
  80. data/lib/r_kit/grid/kernel_extend.rb +0 -14
@@ -1,31 +1,81 @@
1
- class RKit::Grid::Base
2
- class Grid < self
3
- attr_accessor :collection
1
+ class Grid < RKit::Grid::Base
4
2
 
5
- def initialize collection, &block
6
- @collection = collection
3
+ def self.try_convert object, &block
4
+ if object.kind_of? RKit::Grid::Base
5
+ object
7
6
 
8
- @_binding = RKit::Grid::Binding.new
9
- @_binding.block = block
7
+ elsif object.respond_to? :to_grid
8
+ object.to_grid &block
10
9
 
11
- super @_binding
10
+ else
11
+ RKit::Grid::Base::Grid.new Array.wrap(object), &block
12
12
  end
13
+ end
14
+
15
+
16
+ attr_accessor :collection
17
+
18
+ def initialize collection, &block
19
+ @collection = collection
20
+
21
+ @_binding = RKit::Grid::Binding.new
22
+ @_binding.block = block
23
+
24
+ super @_binding
25
+ end
13
26
 
14
- def required_bindings
15
- {
16
- col_size: RKit::Grid.config.col_size,
17
- attributes: {
18
- class: :grid
19
- }
27
+ def required_bindings
28
+ # TODO: change config to min-col-size
29
+ # TODO: col size adapts to collection size, but not below min-col-size
30
+ {
31
+ col_size: RKit::Grid.config.col_size,
32
+ attributes: {
33
+ class: :grid
20
34
  }
21
- end
35
+ }
36
+ end
37
+
22
38
 
23
- def _attributes
24
- _binding.attributes
39
+ class << self
40
+ def binding_accessor name
41
+ define_method name do |value, &block|
42
+ _binding.block = block if block
43
+ _binding.send "#{ name }=", value
44
+
45
+ self
46
+ end
25
47
  end
48
+ end
49
+
50
+ binding_accessor :col_size
51
+ binding_accessor :attributes
52
+ binding_accessor :col_attributes
26
53
 
27
- def capture
28
- GridRow.new(collection, binding: _binding).to_s
54
+
55
+
56
+ def flex &block
57
+ attributes class: 'grid-flex', &block
58
+ end
59
+
60
+ def items value, &block
61
+ attributes class: "grid-items-#{ value }", &block
62
+ end
63
+
64
+
65
+
66
+ def _tag
67
+ :div
68
+ end
69
+
70
+ def _attributes
71
+ _binding.attributes
72
+ end
73
+
74
+ def capture
75
+ collection.map do |object|
76
+ GridCol.new(object, binding: _binding).to_s
29
77
  end
78
+ .reduce(:safe_concat)
30
79
  end
80
+
31
81
  end
@@ -1,26 +1,29 @@
1
- class RKit::Grid::Base
2
- class GridCol < self
3
- attr_accessor :object
1
+ class GridCol < RKit::Grid::Base
2
+ attr_accessor :object
4
3
 
5
- def initialize object, binding:;
6
- @object = object
7
- super binding
8
- end
4
+ def initialize object, binding:;
5
+ @object = object
6
+ super binding
7
+ end
9
8
 
10
- def required_bindings
11
- {
12
- col_attributes: {
13
- class: ->{ :"grid-col-#{ _binding.col_size }" }
14
- }
9
+ def required_bindings
10
+ {
11
+ col_attributes: {
12
+ class: proc{ :"grid-col-#{ _binding.col_size }" }.call
15
13
  }
16
- end
14
+ }
15
+ end
16
+
17
17
 
18
- def _attributes
19
- _binding.col_attributes object
20
- end
18
+ def _tag
19
+ _binding.col_attributes(object)["tag"] || :div
20
+ end
21
+
22
+ def _attributes
23
+ _binding.col_attributes(object).except("tag")
24
+ end
21
25
 
22
- def capture
23
- _binding.capture object
24
- end
26
+ def capture
27
+ _binding.capture object
25
28
  end
26
29
  end
@@ -20,21 +20,7 @@ class RKit::Grid::Base
20
20
  end
21
21
 
22
22
 
23
- class << self
24
- def binding_accessor name
25
- define_method name do |value, &block|
26
- _binding.block = block if block
27
- _binding.send "#{ name }=", value
28
-
29
- self
30
- end
31
- end
32
- end
33
23
 
34
- binding_accessor :col_size
35
- binding_accessor :attributes
36
- binding_accessor :row_attributes
37
- binding_accessor :col_attributes
38
24
 
39
25
 
40
26
  def capture
@@ -42,7 +28,7 @@ class RKit::Grid::Base
42
28
  end
43
29
 
44
30
  def to_s
45
- _h.content_tag :div, _attributes, &method(:capture)
31
+ _h.content_tag _tag, _attributes, &method(:capture)
46
32
  end
47
33
 
48
34
  end
@@ -22,9 +22,6 @@ class RKit::Grid::Binding
22
22
  delegate :attributes=, :attributes,
23
23
  to: :@attributes
24
24
 
25
- delegate :attributes=, :attributes,
26
- to: :@row_attributes, prefix: :row
27
-
28
25
  delegate :attributes=, :attributes,
29
26
  to: :@col_attributes, prefix: :col
30
27
 
@@ -56,7 +53,7 @@ class RKit::Grid::Binding
56
53
  # TODO: Tha last one can be replaced (or duplicated) by a "respond_to?" automatically triggered from here
57
54
  def attributes= attributes
58
55
  @attributes.merge!(attributes) do |key, old_value, new_value|
59
- Array.wrap(old_value) + Array.wrap(new_value)
56
+ Array.wrap(old_value) | Array.wrap(new_value)
60
57
  end
61
58
  end
62
59
 
@@ -72,15 +69,11 @@ class RKit::Grid::Binding
72
69
  def process value, object = nil
73
70
  case value
74
71
  when Proc
75
- proc_value = case value.arity
76
- when 1 then value.call(object)
77
- else value.call
78
- end
79
- process(proc_value, object)
72
+ process(value.call(object), object)
80
73
  when Array
81
74
  value.map{ |unique_value| process(unique_value, object) }.join(' ')
82
75
  when String, Symbol
83
- value.to_s.dasherize
76
+ value.dasherize
84
77
  else
85
78
  raise ArgumentError, 'Must be Array, Proc or String/Symbol'
86
79
  end
@@ -1,26 +1,23 @@
1
1
  .grid {
2
2
  margin: auto;
3
- width: $base_width * 94;
3
+ width: $base_width * 96;
4
4
 
5
- .grid-row {
6
- display: flex;
7
- flex-wrap: wrap;
8
- align-items: baseline;
5
+ display: flex;
6
+ flex-wrap: wrap;
7
+ align-items: baseline;
9
8
 
10
- margin: 0 -#{$base_width};
11
-
12
- @for $col_size from 1 through 12 {
13
- .grid-col-#{ $col_size } {
14
- margin: 0 $base_width;
15
- width: $base_width * (8 * $col_size - 2);
16
- flex-shrink: 0;
17
- }
9
+ @for $col_size from 1 through 12 {
10
+ .grid-col-#{ $col_size } {
11
+ padding: 0 $base_width;
12
+ width: $base_width * 8 * $col_size;
13
+ box-sizing: border-box;
14
+ flex-shrink: 0;
15
+ }
18
16
 
19
- @for $off_size from 1 through 12-$col_size {
20
- .grid-col-#{ $col_size }-off-#{ $off_size } {
21
- @extend .grid-col-#{ $col_size };
22
- margin-left: $base_width * (8 * $off_size + 1);
23
- }
17
+ @for $off_size from 1 through 12-$col_size {
18
+ .grid-col-#{ $col_size }-off-#{ $off_size } {
19
+ @extend .grid-col-#{ $col_size };
20
+ margin-left: $base_width * (8 * $off_size + 1);
24
21
  }
25
22
  }
26
23
  }
@@ -0,0 +1,19 @@
1
+ .grid.grid-flex{
2
+ margin: 0;
3
+ width: auto;
4
+ min-width: $base_width * 96;
5
+
6
+ @for $col_size from 1 through 12 {
7
+ .grid-col-#{ $col_size } {
8
+ width: $col_size * 100 / 12#{'%'};
9
+ min-width: $base_width * 8 * $col_size;
10
+ }
11
+
12
+ @for $off_size from 1 through 12-$col_size {
13
+ .grid-col-#{ $col_size }-off-#{ $off_size } {
14
+ @extend .grid-col-#{ $col_size };
15
+ margin-left: $off_size * 100 / 12#{'%'};
16
+ }
17
+ }
18
+ }
19
+ }
@@ -0,0 +1,5 @@
1
+ @each $align in flex-start flex-end center baseline stretch {
2
+ .grid.grid-items-#{ $align } {
3
+ align-items: $align;
4
+ }
5
+ }
@@ -1,5 +1,7 @@
1
1
  @import "variables/grid";
2
2
  @import "base/grid";
3
+ @import "base/grid_flex";
4
+ @import "base/grid_items";
3
5
 
4
6
 
5
7
 
data/lib/r_kit/grid.rb CHANGED
@@ -7,19 +7,18 @@ class RKit::Grid
7
7
  'base',
8
8
  'base/grid',
9
9
  'base/grid_col',
10
- 'base/grid_row',
11
10
  'binding'
12
11
 
13
12
  load_path __FILE__, 'enumerable_extend', if: :enumerable_extend
14
- load_path __FILE__, 'kernel_extend', if: :kernel_extend
15
13
 
16
14
 
17
15
  config :extends, true
18
16
  alias_config :enumerable_extend, :extends
19
- alias_config :kernel_extend, :extends
20
17
 
21
18
 
22
19
  config :base_width, [0.75, ['rem']]
23
20
  config :col_size, 3
24
21
 
22
+ alias_config :grid_base_width, :base_width
23
+
25
24
  end
@@ -0,0 +1,125 @@
1
+ class RKit::Override::Base
2
+
3
+ def self.override *args
4
+ new(*args).override
5
+ end
6
+
7
+
8
+ attr_accessor :method_name, :method, :pattern, :receiver
9
+
10
+ def initialize method_name, method:, pattern:, pattern_args:, receiver:;
11
+ @method_name = method_name
12
+ @method = method
13
+ @pattern = RKit::Override::Pattern.build(pattern, *pattern_args)
14
+ @receiver = receiver
15
+ end
16
+
17
+ def override
18
+ override_method
19
+ # TODO: hook_method
20
+ end
21
+
22
+
23
+ module Nodef
24
+
25
+ def self.__nodef__ method_name
26
+ define_method :__olddef__ do |*args, &block|
27
+
28
+ if respond_to?(:__getobj__) && __getobj__.respond_to?(method_name)
29
+ __getobj__.send(method_name, *args, &block)
30
+
31
+ else
32
+ owner = self.class.instance_method(method_name).owner
33
+ __newdef__ = owner.instance_method(method_name)
34
+ owner.send :remove_method, method_name
35
+
36
+ closure = if respond_to?(method_name)
37
+ send(method_name, *args, &block)
38
+ end
39
+
40
+ owner.send(:define_method, method_name, __newdef__)
41
+ closure
42
+ end
43
+ end
44
+
45
+ instance_method :__olddef__
46
+ end
47
+
48
+ end
49
+
50
+
51
+ def __olddef__
52
+ __olddef__ = receiver.instance_method(method_name)
53
+
54
+ proc do |*args, &block|
55
+ __olddef__.bind(self).call(*args, &block)
56
+ end
57
+ rescue NameError
58
+ Nodef.__nodef__(method_name)
59
+ end
60
+
61
+ def __newdef__
62
+ method
63
+ end
64
+
65
+
66
+
67
+
68
+
69
+
70
+
71
+
72
+ protected def override_method
73
+ oneself = self
74
+ # override_binding = Module.new{
75
+ # define_method :__olddef__, oneself.__olddef__
76
+ # define_method :__newdef__, oneself.__newdef__
77
+ # define_method :override, oneself.pattern
78
+ # }
79
+
80
+ old_m = oneself.__olddef__
81
+ new_m = oneself.__newdef__
82
+ ove_m = oneself.pattern
83
+
84
+ override_binding = proc{
85
+ define_method :__olddef__, old_m
86
+ define_method :__newdef__, new_m
87
+ define_method :override, ove_m
88
+ }
89
+
90
+ # forget_binding = proc{
91
+ # remove_method :__olddef__
92
+ # remove_method :__newdef__
93
+ # remove_method :override
94
+ # }
95
+
96
+
97
+ receiver.send :define_method, method_name do |*args, &block|
98
+
99
+ #p self.singleton_class.included_modules
100
+ #p
101
+
102
+ # self.extend override_binding #unless self.singleton_class.include?(override_binding)
103
+ # p "add"
104
+
105
+
106
+
107
+ (class << self; self; end).instance_eval &override_binding
108
+
109
+
110
+ closure = self.override *args, &block
111
+ #closure = instance_eval(&ove_m)
112
+
113
+
114
+ # p "delete"
115
+ # (class << self; self; end).class_eval &forget_binding rescue nil
116
+ closure
117
+
118
+ end
119
+ end
120
+
121
+ protected def override_hook
122
+
123
+ end
124
+
125
+ end
@@ -0,0 +1,8 @@
1
+ class Method
2
+
3
+ def simple_override &block
4
+ name = self.name
5
+ receiver.singleton_class.prepend Module.new{ define_method name, &block }
6
+ end
7
+
8
+ end
@@ -0,0 +1,53 @@
1
+ class Module
2
+
3
+ protected def override_method method_name, method: nil, pattern: :standard, pattern_args: [], &block
4
+
5
+ RKit::Override::Base.override method_name,
6
+ method: (method || block),
7
+ pattern: pattern,
8
+ pattern_args: pattern_args,
9
+ receiver: self
10
+
11
+ end
12
+
13
+ protected def override_methods **options, &block
14
+
15
+ carrier = Module.new(&block)
16
+
17
+ carrier.instance_methods(false).each do |method_name|
18
+ override_method method_name, method: carrier.instance_method(method_name), **options
19
+ end
20
+
21
+ carrier.methods(false).each do |method_name|
22
+ singleton_carrier ||= Module.new{ include refine(carrier.singleton_class){} }
23
+ override_singleton_method method_name, method: singleton_carrier.instance_method(method_name), **options
24
+ end
25
+ end
26
+
27
+
28
+
29
+ protected def override_singleton_method *args, &block
30
+ singleton_class.override_method *args, &block
31
+ end
32
+
33
+ protected def override_singleton_methods *args, &block
34
+ singleton_class.override_methods *args, &block
35
+ end
36
+
37
+
38
+
39
+ protected def depend *args, strict: true, **options, &block
40
+ override_methods pattern: (strict && :depend || :if), pattern_args: (args << options), &block
41
+ end
42
+
43
+
44
+
45
+ protected def simple_override_method method_name, &block
46
+ instance_method(method_name).simple_override receiver: self, &block
47
+ end
48
+
49
+ protected def simple_override_singleton_method method_name, &block
50
+ method(method_name).simple_override &block
51
+ end
52
+
53
+ end
@@ -0,0 +1,53 @@
1
+ class RKit::Override::Pattern
2
+
3
+ def self.build *args
4
+ new(*args).build
5
+ end
6
+
7
+
8
+ attr_accessor :pattern, :args
9
+
10
+ def initialize pattern, *args
11
+ @pattern = pattern
12
+ @args = args
13
+ end
14
+
15
+ def build
16
+ send "build_from_#{ pattern.class.name.underscore }"
17
+ end
18
+
19
+
20
+ protected def build_from_proc
21
+ pattern
22
+ end
23
+
24
+ protected def build_from_string
25
+ self.class.const_get("#{ pattern.upcase }_PATTERN").call(*args)
26
+ end
27
+ alias :build_from_symbol :build_from_string
28
+
29
+
30
+ STANDARD_PATTERN = -> *_ do
31
+ ->(*args, &block){ __newdef__(*args, &block) }
32
+ end
33
+
34
+ DEPEND_PATTERN = -> on: do
35
+ -> *args, &block do
36
+ if send(on).present?
37
+ __newdef__(*args, &block)
38
+ else
39
+ nil
40
+ end
41
+ end
42
+ end
43
+
44
+ IF_PATTERN = -> on: do
45
+ -> *args, &block do
46
+ if send(on).present?
47
+ __newdef__(*args, &block)
48
+ else
49
+ __olddef__(*args, &block)
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,117 @@
1
+
2
+ # Perfs
3
+ n = 10_000
4
+ t = Time.now
5
+ n.times {
6
+ c = Class.new{
7
+ def a() "a" end
8
+
9
+ alias :__olddef__a :a
10
+ def a
11
+ __olddef__a << "b"
12
+ end
13
+
14
+ def x() "x" end
15
+
16
+ alias :__olddef__x :x
17
+ def x
18
+ __olddef__x << "y"
19
+ end
20
+ }
21
+ }
22
+ p "#{Time.now - t} : perf (x#{n}) - old school using alias"
23
+
24
+ t = Time.now
25
+ n.times {
26
+ c = Class.new{
27
+ def a() "a" end
28
+
29
+ override_method :a do
30
+ __olddef__ << "b"
31
+ end
32
+
33
+ def x() "x" end
34
+
35
+ override_method :x do
36
+ __olddef__ << "y"
37
+ end
38
+ }
39
+ }
40
+ p "#{Time.now - t} : perf (x#{n}) - override single method (~11x)"
41
+
42
+ t = Time.now
43
+ n.times {
44
+ c = Class.new{
45
+ def a() "a" end
46
+ def x() "x" end
47
+
48
+ override_methods do
49
+ def a
50
+ __olddef__ << "b"
51
+ end
52
+
53
+ def x
54
+ __olddef__ << "y"
55
+ end
56
+ end
57
+ }
58
+ }
59
+ p "#{Time.now - t} : perf (x#{n}) - override multiple methods (~11x)"
60
+
61
+ p "-"
62
+ c_basic = Class.new{
63
+ def initialize
64
+ @a = "a"
65
+ @x = "x"
66
+ end
67
+
68
+ def a() @a end
69
+
70
+ alias :__olddef__a :a
71
+ def a
72
+ __olddef__a << "b"
73
+ end
74
+
75
+ def x() @x end
76
+
77
+ alias :__olddef__x :x
78
+ def x
79
+ __olddef__x << "y"
80
+ end
81
+ }
82
+ c_over = Class.new{
83
+ def initialize
84
+ @a = "a"
85
+ @x = "x"
86
+ end
87
+
88
+ def a() @a end
89
+ def x() @x end
90
+
91
+ override_methods do
92
+ def a
93
+ __olddef__ << "b"
94
+ end
95
+
96
+ def x
97
+ __olddef__ << "y"
98
+ end
99
+ end
100
+ }
101
+ i_basic = c_basic.new
102
+ i_over = c_over.new
103
+
104
+ n = 100_000
105
+ t = Time.now
106
+ n.times {
107
+ i_basic.a
108
+ i_basic.x
109
+ }
110
+ p "#{Time.now - t} : perf (x#{n}) - old school method call"
111
+
112
+ t = Time.now
113
+ n.times {
114
+ i_over.a
115
+ i_over.x
116
+ }
117
+ p "#{Time.now - t} : perf (x#{n}) - override method call (~19x)"