easygoing_active_model 0.1.2

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: af856cefbf62a2fc2189fb2fce3df1d2613cf367
4
+ data.tar.gz: 7aa3446b64c1f2d2a4fffd5cecfa9d181ae1e4c8
5
+ SHA512:
6
+ metadata.gz: 042d1e625f36e7df2b3a0f563ca87d2e9977993d7df4d09f5f126c6206f4603313b8032d4a0270a85950ee6f7108ede58d54e36732d8903032fcfa6ee52166f6
7
+ data.tar.gz: e8e8cb7be8dc9043ccf9ce7c98ce62a592fab59884cc87232dee374e7c3f3700eb8b29d7772bf41b872b44ad9eae00674ff46812b930816c5470acdd4a53e6b3
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ .idea
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.1
4
+ before_install: gem install bundler -v 1.10.6
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in easygoing_active_model.gemspec
4
+ gemspec
@@ -0,0 +1,80 @@
1
+ # EasygoingActiveModel
2
+
3
+ ActiveModel::Model will raise an error if you try to pass in a value that it does not have a setter for. This version of it just skips over such params.
4
+
5
+ For example, imagine the following client class, used in association with any API:
6
+
7
+ ```ruby
8
+ class ClientClass
9
+ include ActiveModel::Model
10
+
11
+ attr_accessor :my_variable_1
12
+ attr_accessor :my_variable_2
13
+
14
+ end
15
+ ```
16
+
17
+ Some controller might have this:
18
+
19
+ ```ruby
20
+
21
+ ClientClass.new(params)
22
+
23
+ ```
24
+
25
+ Or some parent class might do a similar thing:
26
+
27
+ ```ruby
28
+
29
+ class ClientClassParent
30
+
31
+ def initialize(params = {})
32
+ @child_class = ClientClass.new(params[:child_class])
33
+ end
34
+
35
+ end
36
+
37
+ ```
38
+
39
+ Either way, it is possible the hash being passed in to instantiate ClientClass has some parameter other than :my_variable_1 or :my_variable_2. If it does, we'll get an exception.
40
+
41
+ ## Installation
42
+
43
+ Add this line to your application's Gemfile:
44
+
45
+ ```ruby
46
+ gem 'easygoing_active_model'
47
+ ```
48
+
49
+ And then execute:
50
+
51
+ $ bundle
52
+
53
+ Or install it yourself as:
54
+
55
+ $ gem install easygoing_active_model
56
+
57
+ ## Usage
58
+
59
+ Just include EasygoingActiveModel::Model instead of ActiveModel::Model.
60
+
61
+ ```ruby
62
+ class ClientClass
63
+ include EasygoingActiveModel::Model
64
+
65
+ attr_accessor :my_variable_1
66
+ attr_accessor :my_variable_2
67
+
68
+ end
69
+ ```
70
+
71
+ ## Development
72
+
73
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake false` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
74
+
75
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
76
+
77
+ ## Contributing
78
+
79
+ Bug reports and pull requests are welcome on GitHub at https://github.com/avvo/easygoing_active_model.
80
+
@@ -0,0 +1,12 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ require 'rake/testtask'
4
+
5
+ Rake::TestTask.new(:test) do |t|
6
+ t.libs << 'lib'
7
+ t.libs << 'test'
8
+ t.pattern = 'test/**/*_test.rb'
9
+ t.verbose = false
10
+ end
11
+
12
+ task default: :test
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "easygoing_active_model"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'easygoing_active_model/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "easygoing_active_model"
8
+ spec.version = EasygoingActiveModel::VERSION
9
+ spec.authors = ["Seth Ringling"]
10
+ spec.email = ["sringling@avvo.com"]
11
+
12
+ spec.summary = %q{An ActiveModel::Model that does not raise exceptions when you pass a parameter for something undefined.}
13
+ spec.description = %q{An ActiveModel::Model that does not raise exceptions when you pass a parameter for something undefined. Useful in cases where you use an ActiveModel::Model for client classes using an API. When you add a field to your endpoint, you don't want your app raising exceptions before you've started using that new field.}
14
+ spec.homepage = "https://github.com/avvo/easygoing_active_model"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.bindir = "exe"
18
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
+ spec.require_paths = ["lib"]
20
+ spec.test_files = spec.files.grep(%r{^(test|s|features)/})
21
+
22
+ spec.add_dependency 'activemodel'
23
+ spec.add_dependency 'activesupport'
24
+
25
+ spec.add_development_dependency "bundler", "~> 1.10"
26
+ spec.add_development_dependency "rake", "~> 10.0"
27
+ spec.add_development_dependency "minitest"
28
+ end
@@ -0,0 +1,9 @@
1
+ require "easygoing_active_model/version"
2
+ require 'active_support'
3
+ require 'active_support/concern'
4
+ require 'active_model'
5
+ require 'active_model/model'
6
+
7
+ module EasygoingActiveModel
8
+ autoload :Model, 'easygoing_active_model/model'
9
+ end
@@ -0,0 +1,12 @@
1
+ module EasygoingActiveModel
2
+ module Model
3
+ extend ActiveSupport::Concern
4
+ include ActiveModel::Model
5
+
6
+ def initialize(params={})
7
+ params = params.select{|attr, value| self.respond_to?("#{attr}=")}
8
+ super(params)
9
+ end
10
+
11
+ end
12
+ end
@@ -0,0 +1,3 @@
1
+ module EasygoingActiveModel
2
+ VERSION = "0.1.2"
3
+ end
metadata ADDED
@@ -0,0 +1,129 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: easygoing_active_model
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.2
5
+ platform: ruby
6
+ authors:
7
+ - Seth Ringling
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-02-16 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activemodel
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: activesupport
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.10'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.10'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: minitest
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: An ActiveModel::Model that does not raise exceptions when you pass a
84
+ parameter for something undefined. Useful in cases where you use an ActiveModel::Model
85
+ for client classes using an API. When you add a field to your endpoint, you don't
86
+ want your app raising exceptions before you've started using that new field.
87
+ email:
88
+ - sringling@avvo.com
89
+ executables: []
90
+ extensions: []
91
+ extra_rdoc_files: []
92
+ files:
93
+ - ".gitignore"
94
+ - ".travis.yml"
95
+ - Gemfile
96
+ - README.md
97
+ - Rakefile
98
+ - bin/console
99
+ - bin/setup
100
+ - easygoing_active_model.gemspec
101
+ - lib/easygoing_active_model.rb
102
+ - lib/easygoing_active_model/model.rb
103
+ - lib/easygoing_active_model/version.rb
104
+ homepage: https://github.com/avvo/easygoing_active_model
105
+ licenses: []
106
+ metadata: {}
107
+ post_install_message:
108
+ rdoc_options: []
109
+ require_paths:
110
+ - lib
111
+ required_ruby_version: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - ">="
114
+ - !ruby/object:Gem::Version
115
+ version: '0'
116
+ required_rubygems_version: !ruby/object:Gem::Requirement
117
+ requirements:
118
+ - - ">="
119
+ - !ruby/object:Gem::Version
120
+ version: '0'
121
+ requirements: []
122
+ rubyforge_project:
123
+ rubygems_version: 2.4.6
124
+ signing_key:
125
+ specification_version: 4
126
+ summary: An ActiveModel::Model that does not raise exceptions when you pass a parameter
127
+ for something undefined.
128
+ test_files: []
129
+ has_rdoc: