fob 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: 8295caa68f7d14f9ffa35c22ee410938eeeec580
4
- data.tar.gz: 1123352e04f2b1841a22bb9190e1804e40248bc3
3
+ metadata.gz: 3680faf0d0544b9520d59b050afba98433c1dcfd
4
+ data.tar.gz: dbc4664797ac88c4f4c2162cbba1802f61a325e1
5
5
  SHA512:
6
- metadata.gz: 9189afea1e86b19ae692356abf6defe31986143a948c1e76c3ce39fd8df49f026983811bd60bf480a6d4b1d2da09fff55da1aa8a0bda27cae31d43a49c1d2276
7
- data.tar.gz: 923c7d61a129b30034657e9edf1bc88a10d01167e2781d7e6270c2e79d1f05050f50000ed4660888406aff493bbd2e9f333dc3e10b67444ca47b2d735ad352e9
6
+ metadata.gz: 4d7dcfc0c637f70e42ecf1178168b46247748ba46f6524efece3a4a6056216f1f7157eda2358d78c08e3bf0cc2418161f8149b4b3bc46eb4722a84995b4d1bf7
7
+ data.tar.gz: 0fa609503b17725270d10f45ae52e435891e4eec7743ff2e2b6141ef9aa15674a6c9c7e4292b44561f7c85e94a7b87da996d01b4b3a1965669e30408592d8a38
data/README.md CHANGED
@@ -18,7 +18,7 @@ Or install it yourself as:
18
18
 
19
19
  ## Usage
20
20
 
21
- class MyModel < Fob::Fob
21
+ class MyForm < Fob::Fob
22
22
  represents :user, with: :username, :email
23
23
  has_one :company, with: :name
24
24
  attribute :remember_me, Boolean
data/fob.gemspec CHANGED
@@ -18,10 +18,11 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
+ spec.add_dependency "virtus"
22
+ spec.add_dependency "activemodel"
23
+
21
24
  spec.add_development_dependency "bundler", "~> 1.3"
22
25
  spec.add_development_dependency "rake"
23
- spec.add_development_dependency "virtus"
24
- spec.add_development_dependency "activemodel"
25
26
  spec.add_development_dependency "rspec"
26
27
  spec.add_development_dependency "simplecov"
27
28
  end
data/lib/fob/fob.rb ADDED
@@ -0,0 +1,37 @@
1
+ module Fob
2
+
3
+ class Fob
4
+ include Virtus
5
+ extend ActiveModel::Naming
6
+ include ActiveModel::Conversion
7
+ include ActiveModel::Validations
8
+
9
+ def self.represents(name, options={})
10
+ include_model(name, options)
11
+ klass = name.to_s.split("_").collect(&:capitalize).join
12
+ singleton_class.instance_eval do
13
+ define_method(:model_name) do
14
+ ::ActiveModel::Name.new(self, nil, "#{klass}")
15
+ end
16
+ end
17
+ end
18
+
19
+ def self.has_one(name, options={})
20
+ include_model(name, options)
21
+ end
22
+
23
+ def persisted?
24
+ false
25
+ end
26
+
27
+ private
28
+ def self.include_model(name, options)
29
+ class_eval("def #{name.to_s};@#{name.to_s};end")
30
+ class_eval("def #{name.to_s}=(val);@#{name.to_s}=val;end")
31
+ if options[:with]
32
+ delegate *(options[:with]), to: name
33
+ end
34
+ end
35
+ end
36
+
37
+ end
data/lib/fob/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Fob
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/lib/fob.rb CHANGED
@@ -1,41 +1,8 @@
1
- require "fob/version"
1
+ require 'fob/version'
2
2
  require 'active_support/all'
3
3
  require 'virtus'
4
+ require 'fob/fob'
4
5
 
5
6
  module Fob
6
7
 
7
- class Fob
8
- include Virtus
9
- extend ActiveModel::Naming
10
- include ActiveModel::Conversion
11
- include ActiveModel::Validations
12
-
13
- def self.represents(name, options={})
14
- include_model(name, options)
15
- klass = name.to_s.split("_").collect(&:capitalize).join
16
- singleton_class.instance_eval do
17
- define_method(:model_name) do
18
- ::ActiveModel::Name.new(self, nil, "#{klass}")
19
- end
20
- end
21
- end
22
-
23
- def self.has_one(name, options={})
24
- include_model(name, options)
25
- end
26
-
27
- def persisted?
28
- false
29
- end
30
-
31
- private
32
- def self.include_model(name, options)
33
- class_eval("def #{name.to_s};@#{name.to_s};end")
34
- class_eval("def #{name.to_s}=(val);@#{name.to_s}=val;end")
35
- if options[:with]
36
- delegate *(options[:with]), to: name
37
- end
38
- end
39
- end
40
-
41
8
  end
metadata CHANGED
@@ -1,37 +1,37 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fob
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
  - Alex Peachey
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-06-20 00:00:00.000000000 Z
11
+ date: 2013-06-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: bundler
14
+ name: virtus
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - '>='
18
18
  - !ruby/object:Gem::Version
19
- version: '1.3'
20
- type: :development
19
+ version: '0'
20
+ type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - '>='
25
25
  - !ruby/object:Gem::Version
26
- version: '1.3'
26
+ version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: rake
28
+ name: activemodel
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - '>='
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
- type: :development
34
+ type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
@@ -39,21 +39,21 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: virtus
42
+ name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ~>
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: '1.3'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ~>
53
53
  - !ruby/object:Gem::Version
54
- version: '0'
54
+ version: '1.3'
55
55
  - !ruby/object:Gem::Dependency
56
- name: activemodel
56
+ name: rake
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - '>='
@@ -108,6 +108,7 @@ files:
108
108
  - Rakefile
109
109
  - fob.gemspec
110
110
  - lib/fob.rb
111
+ - lib/fob/fob.rb
111
112
  - lib/fob/version.rb
112
113
  - spec/fob/fob_spec.rb
113
114
  - spec/spec_helper.rb