simple_delegate 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/simple_delegate.rb +6 -5
- data/simple_delegate.gemspec +3 -3
- data/spec/simple_delegate_spec.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 844e094ec35e8893844bbf432ed8c06dbbf1de68
|
4
|
+
data.tar.gz: 929a9f5962f497c97fe86a2f3010f33243cb6c62
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d955547a8126eb7e1e4753fb7dc30477b3f57658d2f2a4029d30233334b073b403b193c5a8f47a2a8bd1476ec1a9cd18a4201b053fe78f194df65d44c6fbff97
|
7
|
+
data.tar.gz: a4d2d0b0b34fd6bb37ecdbbb2beff2c82cf09f034130e176527c9bd3d846bcf02a1e4bae1a16b6cd1299e05049ad430167faf13bd927e4156882c5c723920466
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.2
|
data/lib/simple_delegate.rb
CHANGED
@@ -9,15 +9,16 @@ module SimpleDelegate
|
|
9
9
|
|
10
10
|
args.each do |method|
|
11
11
|
define_method(method) do |*method_args, &method_blk|
|
12
|
-
if opts[:
|
13
|
-
object = instance_variable_get("@#{opts.fetch(:
|
14
|
-
|
15
|
-
|
12
|
+
if opts[:to_instance_variable]
|
13
|
+
object = instance_variable_get("@#{opts.fetch(:to_instance_variable)}")
|
14
|
+
raise "Nothing was returned by: #{opts.fetch(:to_instance_variable)}" unless object
|
15
|
+
elsif opts[:to]
|
16
|
+
object = __send__(opts.fetch(:to))
|
17
|
+
raise "Nothing was returned by: #{opts.fetch(:to)}" unless object
|
16
18
|
else
|
17
19
|
raise "Don't know where to delegate to"
|
18
20
|
end
|
19
21
|
|
20
|
-
raise "Nothing was returned by: #{opts.fetch(:to_method)}" unless object
|
21
22
|
object.__send__(method, *method_args, &method_blk)
|
22
23
|
end
|
23
24
|
end
|
data/simple_delegate.gemspec
CHANGED
@@ -2,16 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: simple_delegate 0.0.
|
5
|
+
# stub: simple_delegate 0.0.2 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "simple_delegate"
|
9
|
-
s.version = "0.0.
|
9
|
+
s.version = "0.0.2"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
13
13
|
s.authors = ["kaspernj"]
|
14
|
-
s.date = "2016-04-
|
14
|
+
s.date = "2016-04-09"
|
15
15
|
s.description = "A simple library to delegate methods to instance variables"
|
16
16
|
s.email = "k@spernj.org"
|
17
17
|
s.extra_rdoc_files = [
|
@@ -3,7 +3,7 @@ require "spec_helper"
|
|
3
3
|
class SampleClass1
|
4
4
|
include SimpleDelegate
|
5
5
|
|
6
|
-
delegate :method1, :method2,
|
6
|
+
delegate :method1, :method2, to_instance_variable: :object
|
7
7
|
|
8
8
|
def initialize
|
9
9
|
@object = SampleClass2.new
|
@@ -23,7 +23,7 @@ end
|
|
23
23
|
class DelegateToMethods
|
24
24
|
include SimpleDelegate
|
25
25
|
|
26
|
-
delegate :method1, :method2,
|
26
|
+
delegate :method1, :method2, to: :spawn_object
|
27
27
|
|
28
28
|
def spawn_object
|
29
29
|
@object = SampleClass2.new
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple_delegate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kaspernj
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-04-
|
11
|
+
date: 2016-04-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|