super_struct 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f1671cda7646a760788b60b4e57f2c019d3a2c39
4
- data.tar.gz: b5550c15630c199d189985a6e627918bc7ab2dc7
3
+ metadata.gz: 9a4ceab883ee25bcae184aff63d37e902e5c7d91
4
+ data.tar.gz: a272258f3e3d6afb4eb5bf490bd3b1bb13d490eb
5
5
  SHA512:
6
- metadata.gz: 5d817cb4f2f7d83894ebce53bdf7dd166de9e6bb59e4e9b87bb5b5631aa286ae62fd565bc53e1ac5eacdef595ed98f4637c5b8f7a2d1fd649b1aa3f5ba5760da
7
- data.tar.gz: 667da4f7025e13ba9837a09a6ad7d6f7dfe257aac49181458d5f7c4faa6d0c08ab738ec2c882944966e26b529732e889cd8d9d09b71da83d47035c9d1579a1f4
6
+ metadata.gz: ce9a1c3773fef0b3c47e009edd46cd7022f622e5377e1a8f506bb3324f75ef547fe2b99cf8e4b320220a8ff06e03516140c595355b69a018a84f7732f1702795
7
+ data.tar.gz: 5dfc2e4f7dcf2ea216cde83dd90d5f0f59c3ebe95ca728c9ef33f84f33bc93faa75263d7e32e497a4a625e53c77d25e7545d8ce78f2e7bac218762c5db9469b6
data/README.md CHANGED
@@ -36,6 +36,10 @@ john_doe = Customer.new(attributes)
36
36
  => #<struct Customer name="John Doe">
37
37
  john_doe.name
38
38
  => 'John Doe'
39
+ john_doe.has_attribute?(:name)
40
+ => true
41
+ john_doe.has_attribute?(:dob)
42
+ => false
39
43
  ```
40
44
 
41
45
  ## Testing
@@ -47,7 +51,7 @@ bundle exec rake spec
47
51
 
48
52
  ## Contributing
49
53
 
50
- 1. Fork it ( https://github.com/[my-github-username]/super_struct/fork )
54
+ 1. Fork it ( https://github.com/bramswenson/super_struct/fork )
51
55
  2. Create your feature branch (`git checkout -b my-new-feature`)
52
56
  3. Commit your changes (`git commit -am 'Add some feature'`)
53
57
  4. Push to the branch (`git push origin my-new-feature`)
data/Rakefile CHANGED
@@ -3,7 +3,7 @@ require "rspec/core/rake_task"
3
3
 
4
4
  RSpec::Core::RakeTask.new(:spec)
5
5
 
6
- task :default => :spec
6
+ task :default => [ :spec, :benchmark ]
7
7
 
8
8
  task :benchmark do
9
9
  require 'super_struct'
data/lib/super_struct.rb CHANGED
@@ -33,4 +33,8 @@ module SuperStruct
33
33
  struct.send(:include, InstanceMethods)
34
34
  end
35
35
  end
36
+
37
+ def self.from_hash(hash, &block)
38
+ new(hash, &block).new(hash)
39
+ end
36
40
  end
@@ -1,3 +1,3 @@
1
1
  module SuperStruct
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -32,6 +32,12 @@ describe SuperStruct do
32
32
  end
33
33
  end
34
34
 
35
+ describe '::from_hash' do
36
+ it 'creates a class and instance from the input' do
37
+ expect(SuperStruct.from_hash(input)).to be_a Struct
38
+ end
39
+ end
40
+
35
41
  describe '#new' do
36
42
  context 'given multiple arguments as input' do
37
43
  subject { klass.new(:bar, :bang) }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: super_struct
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bram Swenson