weak_attr_accessor 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 946435bf1509eb0a4880794b29e343854dd6e990
4
+ data.tar.gz: c0540104ab7481e3485e451ad023c11cc0d57f8c
5
+ SHA512:
6
+ metadata.gz: 94e1a1fe6b1708f0d5ade921b5fdf46f8625a6a44c2b3cd3ed92d9327c68ba0aa9dffc98e7e09bfbcbe01758e849b30f11b269be9dd16b9edf72d93114848f00
7
+ data.tar.gz: 07f5f56d65591c8313e390165ce18f304751e55d052b4c4d6d1fdfeac9af7826f87f64272c26a1f5ccd502b476fe77d6c7a3adba527a5dd4a6ec2b7784b056aa
data/.gitignore ADDED
@@ -0,0 +1,6 @@
1
+ .rake_tasks~
2
+ pkg/*
3
+ build/
4
+ .DS_Store
5
+ .repl_history
6
+ 0
data/LICENSE ADDED
@@ -0,0 +1,10 @@
1
+ Copyright (c) 2013, Hwee-Boon Yar
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
5
+
6
+ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7
+
8
+ 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
9
+
10
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
data/README.md ADDED
@@ -0,0 +1,44 @@
1
+ #weak\_attr_accessor for [RubyMotion](http://rubymotion.com)
2
+
3
+ Usage
4
+ ---
5
+ Do this:
6
+
7
+ ```ruby
8
+ class MainView < UIView
9
+ weak_attr_accessor :view_controller
10
+ end
11
+ ```
12
+
13
+ instead of this:
14
+
15
+ ```ruby
16
+ class MainView < UIView
17
+ def view_controller
18
+ @view_controller
19
+ end
20
+
21
+ def view_controller=(obj)
22
+ if obj.nil?
23
+ @view_controller = nil
24
+ else
25
+ @view_controller = WeakRef.new(obj)
26
+ end
27
+ end
28
+ end
29
+ ```
30
+
31
+ Installation
32
+ ---
33
+ 1. Add this to your `Gemfile`: `gem 'weak_attr_accessor'`
34
+ 2. Run `bundle install`
35
+
36
+ License
37
+ ---
38
+ BSD. See LICENSE file.
39
+
40
+ Questions
41
+ ---
42
+ * Email: [hboon@motionobj.com](mailto:hboon@motionobj.com)
43
+ * Web: [http://hboon.com/](http://hboon.com/)
44
+ * Twitter: [http://twitter.com/hboon](http://twitter.com/hboon)
@@ -0,0 +1,9 @@
1
+ unless defined?(Motion::Project::Config)
2
+ raise "This file must be required within a RubyMotion project Rakefile."
3
+ end
4
+
5
+ Motion::Project::App.setup do |app|
6
+ Dir.glob(File.join(File.dirname(__FILE__), 'weak_attr_accessor/**/*.rb')).each do |file|
7
+ app.files.unshift(file)
8
+ end
9
+ end
@@ -0,0 +1,18 @@
1
+ class Class
2
+ #Adapted from https://gist.github.com/johnclaus/959944
3
+ def weak_attr_accessor(*my_accessors)
4
+ my_accessors.each do |accessor|
5
+ define_method(accessor) do
6
+ instance_variable_get("@#{accessor}")
7
+ end
8
+
9
+ define_method("#{accessor}=") do |accessor_value|
10
+ if accessor_value.nil?
11
+ instance_variable_set("@#{accessor}", nil)
12
+ else
13
+ instance_variable_set("@#{accessor}", WeakRef.new(accessor_value))
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,3 @@
1
+ module WeakAttrAccessor
2
+ VERSION = '0.0.1'
3
+ end
@@ -0,0 +1,19 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/weak_attr_accessor/version.rb', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.name = 'weak_attr_accessor'
6
+ gem.version = WeakAttrAccessor::VERSION
7
+ gem.licenses = ['BSD']
8
+
9
+ gem.authors = ['Hwee-Boon Yar']
10
+
11
+ gem.description = 'Adds weak_attr_accessor that wraps objects with WeakRef'
12
+ gem.summary = 'Adds weak_attr_accessor that wraps objects with WeakRef'
13
+ gem.homepage = 'https://github.com/hboon/weak_attr_accessor'
14
+ gem.email = 'hboon@motionobj.com'
15
+
16
+ gem.files = `git ls-files`.split($\)
17
+ gem.require_paths = ['lib']
18
+ #gem.test_files = gem.files.grep(%r{^spec/})
19
+ end
metadata ADDED
@@ -0,0 +1,50 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: weak_attr_accessor
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Hwee-Boon Yar
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-01-31 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Adds weak_attr_accessor that wraps objects with WeakRef
14
+ email: hboon@motionobj.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - ".gitignore"
20
+ - LICENSE
21
+ - README.md
22
+ - lib/weak_attr_accessor.rb
23
+ - lib/weak_attr_accessor/class.rb
24
+ - lib/weak_attr_accessor/version.rb
25
+ - weak_attr_accessor.gemspec
26
+ homepage: https://github.com/hboon/weak_attr_accessor
27
+ licenses:
28
+ - BSD
29
+ metadata: {}
30
+ post_install_message:
31
+ rdoc_options: []
32
+ require_paths:
33
+ - lib
34
+ required_ruby_version: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ">="
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ required_rubygems_version: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ requirements: []
45
+ rubyforge_project:
46
+ rubygems_version: 2.4.2
47
+ signing_key:
48
+ specification_version: 4
49
+ summary: Adds weak_attr_accessor that wraps objects with WeakRef
50
+ test_files: []