auto_demeter 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -1 +1 @@
1
- require "bundler/gem_tasks"
1
+ require 'bundler/gem_tasks'
data/auto_demeter.gemspec CHANGED
@@ -4,19 +4,19 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'auto_demeter/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
- spec.name = "auto_demeter"
8
- spec.version = AutoDemeter::VERSION
9
- spec.authors = ["Paul McKibbin"]
10
- spec.email = ["pmckibbin@gmail.com"]
11
- spec.description = %q{Create automated methods for all children or parents to allow a request to be handled more easily than defining a long chain}
12
- spec.summary = %q{Automated demeter methods}
13
- spec.homepage = ""
14
- spec.license = "MIT"
7
+ spec.name = 'auto_demeter'
8
+ spec.version = AutoDemeter::VERSION
9
+ spec.authors = ['Paul McKibbin']
10
+ spec.email = ['pmckibbin@gmail.com']
11
+ spec.description = %q{Create automated methods for all children or parents to allow a request to be handled more easily than defining a long chain}
12
+ spec.summary = %q{Automated demeter methods}
13
+ spec.homepage = ''
14
+ spec.license = 'MIT'
15
15
 
16
- spec.files = `git ls-files`.split($/)
17
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
- spec.require_paths = ["lib"]
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ['lib']
20
20
 
21
21
  spec.add_development_dependency 'sqlite3'
22
22
 
@@ -17,7 +17,11 @@ module AutoDemeter
17
17
  def respond_through_association?(method_id)
18
18
  if children_names && (match_data=method_id.to_s.match(reflected_children_regex)) && match_data[1].present?
19
19
  association_name=self.methods.include?(match_data[1]) ? match_data[1] : "#{self.class.name.underscore}_#{match_data[1]}"
20
- send(association_name) ? true : match_data[2][0..2] == 'is_'
20
+ begin
21
+ send(association_name) ? true : match_data[2][0..2] == 'is_'
22
+ rescue
23
+ false
24
+ end
21
25
  else
22
26
  false
23
27
  end
@@ -31,13 +35,17 @@ module AutoDemeter
31
35
  def method_missing(method_id, *args, &block)
32
36
  begin
33
37
  super
34
- rescue NoMethodError, NameError
38
+ rescue NoMethodError, NameError => e
35
39
  if match_data=method_id.to_s.match(reflected_children_regex)
36
40
  association_name=self.respond_to?(match_data[1]) ? match_data[1] : "#{self.class.name.underscore}_#{match_data[1]}"
37
- if association=send(association_name)
38
- association.send(match_data[2], *args, &block)
39
- else
40
- match_data[2][0..2] == 'is_' ? match_data[2][3..6] == 'not_' : nil
41
+ begin
42
+ if association=send(association_name)
43
+ association.send(match_data[2], *args, &block)
44
+ else
45
+ match_data[2][0..2] == 'is_' ? match_data[2][3..6] == 'not_' : nil
46
+ end
47
+ rescue Exception
48
+ raise e
41
49
  end
42
50
  else
43
51
  raise
@@ -1,3 +1,3 @@
1
1
  module AutoDemeter
2
- VERSION = "0.0.3"
2
+ VERSION = '0.0.4'
3
3
  end
@@ -10,7 +10,7 @@ end
10
10
  $:.unshift File.dirname(__FILE__) + '/../lib'
11
11
  require File.dirname(__FILE__) + '/../lib/auto_demeter'
12
12
 
13
- ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :database => ":memory:")
13
+ ActiveRecord::Base.establish_connection(:adapter => 'sqlite3', :database => ':memory:')
14
14
 
15
15
  def setup_db
16
16
  ActiveRecord::Base.logger
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: auto_demeter
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 3
10
- version: 0.0.3
9
+ - 4
10
+ version: 0.0.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Paul McKibbin
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2016-03-19 00:00:00 Z
18
+ date: 2016-04-27 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: sqlite3