lazy_record 0.6.3 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 56bce37d54f4018b548f48e32c8605d63bced313
4
- data.tar.gz: 1d1df3c2c2285cd238f49ead0d883897c6a8dc2e
3
+ metadata.gz: fee6bdb6da8c27b811ad1cb292ddaab4d7828f33
4
+ data.tar.gz: a5b556eea6d24c24baac786eb06b18801cfe1991
5
5
  SHA512:
6
- metadata.gz: 0acbf3c1895d7bd1501f7f4558dae2f548273eda3052d0b6f2b4a236232ed5db0b6da310c09634ca340a89f44a24192851d729144c067ab54839998ece509ad7
7
- data.tar.gz: 96fea24cfc627e8f88d6ca0dd45c8122daaeef7c5aa6ce40ee345ae51d2e7a47866a54f6314b7e853a732853ccb486169c28268ac5f30113e8d02871f1522955
6
+ metadata.gz: 9fa0cfb63cbe0d972b59442df3f0cd9c5173792ac551109ea0e4be7ba4609f286e1784991c96b96624af442e6dc1972f13e6349f7b5316db5fbeb1347b8ea070
7
+ data.tar.gz: f0e9a7b71f97167e4fc41ae6874e5bc23b0bdec00f4f119f801ba9e7d0017cae02f9dff719ab4dbd5d487b59752ee6f189a0ce16a7e420d6e26a67f2024323d4
data/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
  [![Build Status](https://travis-ci.org/msimonborg/lazy_record.svg?branch=master)](https://travis-ci.org/msimonborg/lazy_record)
5
5
  [![Coverage Status](https://coveralls.io/repos/github/msimonborg/lazy_record/badge.svg?branch=master)](https://coveralls.io/github/msimonborg/lazy_record?branch=master)
6
6
 
7
- LazyRecord writes a bunch of boilerplate code for your POROs, similarly to what you'd expect ActiveRecord to do for your database-backed objects. This project is an attempt to understand and explore dynamic programming techniques in Ruby, and demystify some of the Rails magic. Maybe someone will find it useful.
7
+ LazyRecord writes a bunch of boilerplate code for your POROs, similarly to what you'd expect ActiveRecord to do for your database-backed objects. The main use case is for working with objects returned by external APIs. This gem can be added as a dependency to your ruby API wrapper to easily enhance your gem's public API. See [PYR](https://github.com/msimonborg/pyr) as an example.
8
8
 
9
9
  ## Installation
10
10
 
@@ -35,7 +35,7 @@ thing = Thing.new { |t| puts t.class.superclass }
35
35
  # => #<Thing>
36
36
  ```
37
37
 
38
- Alternatively, if you want to inherit from another class, you can mix in the `LazyRecord::BaseModule` and get all the same results.
38
+ Alternatively, if you want to inherit from another class, you can mix in the `LazyRecord::BaseModule` and get all the same features.
39
39
 
40
40
  ```ruby
41
41
  class Thing
@@ -46,7 +46,6 @@ thing = Thing.new { |t| puts t.class.superclass }
46
46
  # Object
47
47
  # => #<Thing>
48
48
  ```
49
- Every LazyRecord object is assigned an auto-incrementing ID after initialization. IDs reset when the program is terminated.
50
49
 
51
50
  Use `attr_accessor` like you would use normally, and you'll get hash syntax in your `#intialize` method for attribute setting. The attributes will also be visible when the object is returned or `inspected`. Attributes defined with `attr_reader` will also be visible, but `attr_writers`, custom getters and writers, and other methods will not.
52
51
 
@@ -166,7 +165,7 @@ Whatever.low_sleepy
166
165
  Whatever.where party_value: 12
167
166
  # => #<WhateverRelation [#<Whatever party_value: 12, sleepy_value: 12>
168
167
  ```
169
- You can also use hash syntax and block syntax with `.where`. Block syntax will yield each object in the collection to the block for evaluation.
168
+ You can use hash syntax and block syntax with `.where`. Block syntax acts like `Enumerable#select` and will yield each object in the collection to the block for evaluation.
170
169
  ```ruby
171
170
  Whatever.where { |w| w.sleepy_value > 5 }
172
171
  # => #<WhateverRelation [#<Whatever party_value: 12, sleepy_value: 12>, #<Whatever id: 3, party_value: 4, sleepy_value: 11>]>
@@ -183,7 +182,9 @@ num = 6
183
182
  Whatever.where party_value: -> { num * 2 }
184
183
  # => #<WhateverRelation [#<Whatever party_value: 12, sleepy_value: 12>]>
185
184
  ```
186
- Use `lr_method` for an alternative API for defining short instance methods using lambda syntax. The first argument passed to the block must be the receiver of the method, or `self` in the method scope.
185
+ Use `lr_method` for an alternative API for defining short instance methods using lambda syntax.
186
+
187
+ `lr_method` and `lr_scope` work identically except the former is for instance methods and evaluates `self` in the instance scope, while the latter defines class methods and `self` is evaluated in the class scope.
187
188
 
188
189
  ```ruby
189
190
  class Whatever < LazyRecord::Base
@@ -196,8 +197,8 @@ class Thing < LazyRecord::Base
196
197
  attr_accessor :stuff, :junk
197
198
  lr_validates :stuff, presence: true
198
199
  lr_has_many :whatevers
199
- lr_method :speak, -> (_x, string) { puts string }
200
- lr_method :what_am_i, ->(x) { "I'm a #{x.class}" }
200
+ lr_method :speak, -> (string) { puts string }
201
+ lr_method :what_am_i, -> { "I'm a #{self.class}" }
201
202
  end
202
203
 
203
204
  thing = Thing.new stuff: 'stuff'
@@ -210,6 +211,8 @@ thing.what_am_i
210
211
  ## Platform support
211
212
 
212
213
  Tested against:
214
+ * MRI 2.1.0
215
+ * MRI 2.2.2
213
216
  * MRI 2.3.0
214
217
  * MRI 2.3.4
215
218
  * MRI 2.4.1
@@ -28,10 +28,10 @@ require 'lazy_record/version'
28
28
  require 'lazy_record/associations'
29
29
  require 'lazy_record/attributes'
30
30
  require 'lazy_record/callbacks'
31
+ require 'lazy_record/class_methods'
31
32
  require 'lazy_record/collections'
32
33
  require 'lazy_record/dynamic_modules'
33
34
  require 'lazy_record/methods'
34
- require 'lazy_record/nesting'
35
35
  require 'lazy_record/scopes'
36
36
  require 'lazy_record/validations'
37
37
  require 'lazy_record/relation'
@@ -1,12 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'lazy_record/nesting'
4
-
5
3
  module LazyRecord
6
4
  # Set up in-memory one-to-one associations between POROs.
7
5
  module Associations
8
- include LazyRecord::Nesting
9
-
10
6
  ASSOCIATION_MODULE_NAME = :Associations
11
7
 
12
8
  def lr_has_one(*args)
@@ -40,10 +36,10 @@ module LazyRecord
40
36
  end
41
37
 
42
38
  def define_association_setter(assoc)
43
- model = find_scoped_association_class(assoc)
39
+ klass = const_get(assoc.to_s.camelize)
44
40
  define_method("#{assoc}=") do |val|
45
- return instance_variable_set("@#{assoc}", val) if val.is_a? model.call
46
- raise ArgumentError, "Argument must be a #{model.call}"
41
+ return instance_variable_set("@#{assoc}", val) if val.is_a? klass
42
+ raise ArgumentError, "Argument must be a #{klass}"
47
43
  end
48
44
  end
49
45
 
@@ -52,9 +48,5 @@ module LazyRecord
52
48
  instance_variable_get("@#{association}")
53
49
  end
54
50
  end
55
-
56
- def find_scoped_association_class(association)
57
- -> { apply_nesting(association.to_s.camelize).constantize }
58
- end
59
51
  end
60
52
  end
@@ -8,6 +8,6 @@ module LazyRecord
8
8
  # method generating macros, scope methods and scope chaining, associations
9
9
  # with other objects, and validations. This is a WIP still in development.
10
10
  class Base
11
- include BaseModule
11
+ include LazyRecord::BaseModule
12
12
  end
13
13
  end
@@ -4,18 +4,23 @@ module LazyRecord
4
4
  # This module gives the Base class its functionality, and can be included
5
5
  # in any class as an alternative to inheriting from LazyRecord::Base
6
6
  module BaseModule
7
+ # Modules that compose the functionality of the LazyRecord API
8
+ LAZY_RECORD_MODULES = [
9
+ ClassMethods,
10
+ Scopes,
11
+ Attributes,
12
+ Collections,
13
+ Associations,
14
+ Callbacks,
15
+ Validations,
16
+ Methods,
17
+ DynamicModules
18
+ ].freeze
19
+
7
20
  # Extend these modules when BaseModule is included
8
21
  def self.included(base)
9
22
  base.extend ScopedAttrAccessor
10
- base.extend ClassMethods
11
- base.extend Scopes
12
- base.extend Attributes
13
- base.extend Collections
14
- base.extend Associations
15
- base.extend Callbacks
16
- base.extend Validations
17
- base.extend Methods
18
- base.extend DynamicModules
23
+ LAZY_RECORD_MODULES.each { |mod| base.extend mod }
19
24
  end
20
25
 
21
26
  # Use options hash to set attributes, and/or operate on object in a block.
@@ -109,42 +114,5 @@ module LazyRecord
109
114
  :collection_counts_to_s,
110
115
  :associations_to_s,
111
116
  :set_equality_conditions
112
-
113
- # Class methods provided to all LazyRecord classes
114
- module ClassMethods
115
- def public_attr_readers
116
- @public_attr_readers ||= attr_readers.reject do |reader|
117
- private_method_defined?(reader) || protected_method_defined?(reader)
118
- end
119
- end
120
-
121
- def attr_readers
122
- @attr_readers ||= []
123
- end
124
-
125
- def all
126
- @all ||= Relation.new(model: self)
127
- end
128
-
129
- def count
130
- all.count
131
- end
132
-
133
- def first
134
- all.first
135
- end
136
-
137
- def last
138
- all.last
139
- end
140
-
141
- def where(condition = nil, &block)
142
- all.where(condition, &block)
143
- end
144
-
145
- def destroy_all
146
- all.send(:clear)
147
- end
148
- end
149
117
  end
150
118
  end
@@ -6,7 +6,7 @@ module LazyRecord
6
6
  # After #initialize callbacks for validations and setting object id.
7
7
  module Callbacks
8
8
  def new(opts = {})
9
- @all ||= Relation.new(model: self)
9
+ @all ||= Relation.new(klass: self)
10
10
  instance = super(opts)
11
11
  if instance.respond_to?(:validation)
12
12
  instance = instance.validation(*@validations)
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ module LazyRecord
4
+ # Class methods extended to all LazyRecord descendants.
5
+ module ClassMethods
6
+ def public_attr_readers
7
+ @public_attr_readers ||= attr_readers.reject do |reader|
8
+ private_method_defined?(reader) || protected_method_defined?(reader)
9
+ end
10
+ end
11
+
12
+ def attr_readers
13
+ @attr_readers ||= []
14
+ end
15
+
16
+ def all
17
+ @all ||= Relation.new(klass: self)
18
+ end
19
+
20
+ def count
21
+ all.count
22
+ end
23
+
24
+ def first
25
+ all.first
26
+ end
27
+
28
+ def last
29
+ all.last
30
+ end
31
+
32
+ def where(condition = nil, &block)
33
+ all.where(condition, &block)
34
+ end
35
+
36
+ def destroy_all
37
+ all.send(:clear)
38
+ end
39
+ end
40
+ end
@@ -1,92 +1,109 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'lazy_record/nesting'
4
-
5
3
  module LazyRecord
6
4
  # Set up in-memory one-to-many relationships between objects
7
5
  module Collections
8
- include LazyRecord::Nesting
9
-
10
6
  COLLECTION_MODULE_NAME = :Collections
11
7
  NESTED_ATTRS_MODULE_NAME = :NestedAttributes
12
8
 
13
- def define_collection_getter(collection)
14
- model = find_scoped_collection_class(collection)
15
- define_method(collection) do
16
- if instance_variable_get("@#{collection}").nil?
17
- instance_variable_set("@#{collection}", Relation.new(model: model))
9
+ def _define_collection_getter(collection, options)
10
+ klass = const_get(options[:class_name])
11
+ module_eval <<-RUBY, __FILE__, __LINE__ + 1
12
+ def #{collection}
13
+ @#{collection} ||= Relation.new(klass: #{klass})
18
14
  end
19
- instance_variable_get("@#{collection}")
20
- end
15
+ RUBY
21
16
  end
22
17
 
23
- def define_collection_setter(collection)
24
- model = find_scoped_collection_class(collection)
25
- define_method("#{collection}=") do |coll|
26
- coll = Relation.new(model: model, array: coll)
27
- instance_variable_set("@#{collection}", coll)
28
- end
18
+ def _define_collection_setter(collection, options)
19
+ klass = const_get(options[:class_name])
20
+ module_eval <<-RUBY, __FILE__, __LINE__ + 1
21
+ def #{collection}=(coll)
22
+ @#{collection} = Relation.new(klass: #{klass}, collection: coll)
23
+ end
24
+ RUBY
29
25
  end
30
26
 
31
- def find_scoped_collection_class(collection)
32
- -> { apply_nesting(collection.to_s.classify).constantize }
27
+ def _define_collection_counter(collection)
28
+ module_eval <<-RUBY, __FILE__, __LINE__ + 1
29
+ def #{collection}_count
30
+ #{collection}.count
31
+ end
32
+ RUBY
33
33
  end
34
34
 
35
- def define_collection_counter(collection)
36
- define_method("#{collection}_count") do
37
- send(collection).count
35
+ def _add_to_collections(*collections)
36
+ options = collections.extract_options!
37
+ collections.each do |collection|
38
+ class_name = options[:class_name] || collection.to_s.classify
39
+ _collections[collection.to_sym] = { class_name: class_name }
38
40
  end
39
41
  end
40
42
 
41
- def define_collections(*collections)
42
- define_method(:collections) do
43
- collections
44
- end
43
+ def _collections
44
+ @_collections ||= {}
45
45
  end
46
46
 
47
- def define_collection_counts_to_s
47
+ def _define_collection_counts_to_s
48
48
  define_method(:collection_counts_to_s) do
49
- collections.map do |collection|
49
+ collections.map do |collection, _options|
50
50
  "#{collection}_count: #{stringify_value(send("#{collection}_count"))}"
51
51
  end
52
52
  end
53
53
  private :collection_counts_to_s
54
54
  end
55
55
 
56
+ def _define_collections
57
+ collections = _collections
58
+ define_method(:collections) { collections }
59
+ end
60
+
56
61
  def lr_has_many(*collections)
57
62
  include mod = get_or_set_mod(COLLECTION_MODULE_NAME)
58
63
  mod.extend(Collections)
59
- mod.module_eval { add_collection_methods(collections) }
64
+ mod.module_eval { _add_collection_methods(*collections) }
60
65
  end
61
66
 
62
- def add_collection_methods(collections)
63
- define_collections(*collections)
64
- define_collection_counts_to_s
65
- collections.each do |collection|
66
- define_collection_getter(collection)
67
- define_collection_setter(collection)
68
- define_collection_counter(collection)
67
+ def _add_collection_methods(*collections)
68
+ _add_to_collections(*collections)
69
+ _define_collections
70
+ _define_collection_counts_to_s
71
+ _collections.each do |collection, options|
72
+ _define_collection_getter(collection, options)
73
+ _define_collection_setter(collection, options)
74
+ _define_collection_counter(collection)
69
75
  end
70
76
  end
71
77
 
72
- def define_collection_attributes_setter(collection, class_name)
73
- define_method("#{collection}_attributes=") do |collection_attributes|
74
- collection_attributes.values.each do |attributes|
75
- send(collection) << class_name.new(attributes)
78
+ def define_collection_attributes_setter(collection, options)
79
+ class_name = const_get(options.fetch(:class_name))
80
+ module_eval <<-RUBY, __FILE__, __LINE__ + 1
81
+ def #{collection}_attributes=(collection_attributes)
82
+ collection_attributes.values.each do |attributes|
83
+ #{collection} << #{class_name}.new(attributes)
84
+ end
76
85
  end
77
- collection
78
- end
86
+ RUBY
79
87
  end
80
88
 
81
89
  def lr_accepts_nested_attributes_for(*collections)
82
- include mod = get_or_set_mod(NESTED_ATTRS_MODULE_NAME)
90
+ include mod = get_or_set_mod(COLLECTION_MODULE_NAME)
83
91
  mod.extend(Collections)
84
92
  mod.module_eval do
85
93
  collections.each do |collection|
86
- class_name = collection.to_s.classify.constantize
87
- define_collection_attributes_setter(collection, class_name)
94
+ options = _collections[collection]
95
+ _no_collection_error(collection) unless options
96
+ define_collection_attributes_setter(collection, options)
88
97
  end
89
98
  end
90
99
  end
100
+
101
+ def _no_collection_error(collection)
102
+ klass = collection.to_s.classify
103
+ klass = _collections.find { |_col, opt| opt[:class_name] == klass }.first
104
+ suggestion = klass ? ". Did you mean #{klass}?" : ''
105
+ msg = "#{self} doesn't have a collection of #{collection}#{suggestion}"
106
+ raise ArgumentError, msg, caller
107
+ end
91
108
  end
92
109
  end
@@ -5,14 +5,34 @@ module LazyRecord
5
5
  module Methods
6
6
  METHODS_MODULE_NAME = :DynamicMethods
7
7
 
8
+ # Defines an instance method on the calling class. The first agrument
9
+ # is a symbol that names the method. The second argument should be a lambda
10
+ # that defines the method execution. The method argument could technically
11
+ # be any object that responds to #to_proc and returns a Proc, but lambdas
12
+ # with their arity restrictions are preferred.
13
+ #
14
+ # === Example
15
+ # class Thing < LazyRecord::Base
16
+ # lr_method :say_hi, -> { "Hi from #{self}" }
17
+ # end
18
+ #
19
+ # thing = Thing.new # => #<Thing>
20
+ # thing.say_hi # => "Hi from #<Thing:0x007fb9629c6260>"
21
+ #
22
+ # @api public
23
+ #
24
+ # @param method_name [Symbol, String]
25
+ # @param method [Proc]
26
+ #
27
+ # @return [Symbol]
8
28
  def lr_method(method_name, method)
9
- include mod = get_or_set_mod(METHODS_MODULE_NAME)
29
+ mod = get_or_set_mod(METHODS_MODULE_NAME)
10
30
 
11
31
  mod.module_eval do
12
- define_method(method_name) do |*args|
13
- method.call(self, *args)
14
- end
32
+ define_method(method_name.to_sym, &method)
15
33
  end
34
+
35
+ include mod unless include?(mod)
16
36
  end
17
37
  end
18
38
  end
@@ -6,29 +6,37 @@ module LazyRecord
6
6
  class Relation
7
7
  include Enumerable
8
8
 
9
- attr_reader :model, :all
9
+ attr_reader :klass, :all
10
10
 
11
- def initialize(model:, array: nil)
12
- model = model.call if model.is_a? Proc
13
- raise ArgumentError, 'model must be a class' unless model.is_a?(Class)
14
- @model = model
11
+ def initialize(klass:, collection: [])
12
+ klass = klass.call if klass.is_a? Proc
13
+ klass_argument_error unless klass.is_a?(Class)
14
+ @klass = klass
15
15
  @all = []
16
16
  self_extend_scopes_module
17
- array&.each do |object|
18
- @all << object && next if object.is_a?(model)
19
- message = "Argument must be a collection of #{model.to_s.tableize}"
20
- raise ArgumentError, message
17
+ collection.each do |object|
18
+ @all << object && next if object.is_a?(klass)
19
+ collection_argument_error
21
20
  end
22
21
  end
23
22
 
23
+ def collection_argument_error
24
+ message = "Argument must be a collection of #{klass.to_s.tableize}"
25
+ raise ArgumentError, message
26
+ end
27
+
28
+ def klass_argument_error
29
+ raise ArgumentError, '`klass` keyword argument must be a class'
30
+ end
31
+
24
32
  def <<(other)
25
- message = "object must be of type #{model}"
26
- raise ArgumentError, message unless other.is_a?(model)
33
+ message = "object must be of type #{klass}"
34
+ raise ArgumentError, message unless other.is_a?(klass)
27
35
  all << other unless all.include?(other)
28
36
  end
29
37
 
30
38
  def inspect
31
- "\#<#{model}Relation [#{all.map(&:inspect).join(', ')}]>"
39
+ "\#<#{klass}Relation [#{all.map(&:inspect).join(', ')}]>"
32
40
  end
33
41
 
34
42
  def where(condition = nil)
@@ -39,7 +47,7 @@ module LazyRecord
39
47
  yield instance
40
48
  end
41
49
  end
42
- self.class.new(model: model, array: result)
50
+ self.class.new(klass: klass, collection: result)
43
51
  end
44
52
 
45
53
  def select_by_hash_condition(condition, instance)
@@ -72,9 +80,9 @@ module LazyRecord
72
80
  private :clear, :all, :select_by_hash_condition
73
81
 
74
82
  def self_extend_scopes_module
75
- return unless model.const_defined?(Scopes::SCOPE_MODULE_NAME,
83
+ return unless klass.const_defined?(Scopes::SCOPE_MODULE_NAME,
76
84
  _search_ancestors = false)
77
- extend(model.const_get(Scopes::SCOPE_MODULE_NAME))
85
+ extend(klass.const_get(Scopes::SCOPE_MODULE_NAME))
78
86
  end
79
87
  end
80
88
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LazyRecord
4
- VERSION = '0.6.3'
4
+ VERSION = '0.7.0'
5
5
  end
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lazy_record
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.3
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - M. Simon Borg
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-07-01 00:00:00.000000000 Z
11
+ date: 2017-07-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '5.0'
19
+ version: 3.0.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '5.0'
26
+ version: 3.0.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: scoped_attr_accessor
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -77,10 +77,10 @@ files:
77
77
  - lib/lazy_record/base.rb
78
78
  - lib/lazy_record/base_module.rb
79
79
  - lib/lazy_record/callbacks.rb
80
+ - lib/lazy_record/class_methods.rb
80
81
  - lib/lazy_record/collections.rb
81
82
  - lib/lazy_record/dynamic_modules.rb
82
83
  - lib/lazy_record/methods.rb
83
- - lib/lazy_record/nesting.rb
84
84
  - lib/lazy_record/relation.rb
85
85
  - lib/lazy_record/scopes.rb
86
86
  - lib/lazy_record/validations.rb
@@ -98,7 +98,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
98
98
  requirements:
99
99
  - - ">="
100
100
  - !ruby/object:Gem::Version
101
- version: 2.3.0
101
+ version: 2.1.0
102
102
  required_rubygems_version: !ruby/object:Gem::Requirement
103
103
  requirements:
104
104
  - - ">="
@@ -1,10 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module LazyRecord
4
- # Apply the same namespace nesting as self to another object.
5
- module Nesting
6
- def apply_nesting(class_name)
7
- "#{to_s.split('::')[0..-3].join('::')}::#{class_name}"
8
- end
9
- end
10
- end