sentient_model 1.0.1 → 1.0.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.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sentient_model (1.0.0)
4
+ sentient_model (1.0.2)
5
5
  bundler (>= 1.0)
6
6
 
7
7
  GEM
data/README.md ADDED
@@ -0,0 +1,35 @@
1
+ # sentient_model
2
+
3
+ sentient_model is simple piece of code trying to solve a common problem.
4
+
5
+ Imagine you are writing an authentication system for [Ruby on Rails](http://rubyonrails.org). Usually you would define a method called `current_user` in your `ApplicationController` and expose it to your views and so on (which is fine in most cases).
6
+
7
+ However, if you need `current_user` in locations where you can't easily expose the method, sentient_model is the perfect solution. Instead of manually exposing `current_user`, you would just rely on `User.current`. sentient_model's methods are globally accessible - therefore you don't have to worry about anything - it just works.
8
+
9
+ ## Usage
10
+
11
+ Define your models as usual and include the module `SentientModel`:
12
+
13
+ class YourModel
14
+ include SentientModel
15
+ # more code such as validations or associations
16
+ end
17
+
18
+ By including `SentientModel`, the following methods are added to your model:
19
+
20
+ YourModel#make_current # instance method - makes the callee object the sentient object
21
+ YourModel#current? # instance method - true if the callee is the current sentient object or false otherwise
22
+ YourModel.current # class method - returns the sentient object or nil
23
+ YourModel.current=(m) # class method - sets the sentient object to the supplied argument (must be an instance of YourModel)
24
+ YourModel.has_current? # class method - true if a sentient object defined or false otherwise
25
+
26
+ ## Compatibility
27
+
28
+ * MRI Ruby 1.8.7
29
+ * MRI Ruby 1.9.2
30
+ * JRuby 1.6
31
+
32
+ ## How to contribute?
33
+
34
+ 1. Fork on [GitHub](http://github.com/cs/sentient_model).
35
+ 2. Send Pull Request.
@@ -1,9 +1,9 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'sentient_model'
3
- s.version = '1.0.1'
3
+ s.version = '1.0.2'
4
4
  s.platform = Gem::Platform::RUBY
5
- s.summary = 'Define variables available to an entire request with ease.'
6
- s.description = 'Inspired by sentient_user Gem.'
5
+ s.summary = 'Simple piece of code trying to solve a common problem.'
6
+ s.description = 'Replace methods like `current_account` in your controllers with globally accessible methods like `Account.current`.'
7
7
 
8
8
  s.required_ruby_version = '>= 1.8.7'
9
9
  s.required_rubygems_version = ">= 1.3.6"
@@ -20,6 +20,7 @@ Gem::Specification.new do |s|
20
20
  s.require_path = "lib"
21
21
 
22
22
  s.files = [
23
+ "README.md",
23
24
  "Rakefile",
24
25
  "Gemfile",
25
26
  "Gemfile.lock",
@@ -52,8 +52,10 @@ describe SentientModel do
52
52
  @foo = TestClass.new.make_current
53
53
  @bar = OtherTestClass.new.make_current
54
54
  end
55
+ it { TestClass.has_current?.should be_true }
55
56
  it { TestClass.current.should eql(@foo) }
56
57
  it { TestClass.current.should_not eql(@bar) }
58
+ it { OtherTestClass.has_current?.should be_true }
57
59
  it { OtherTestClass.current.should eql(@bar) }
58
60
  it { OtherTestClass.current.should_not eql(@foo) }
59
61
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sentient_model
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 1
10
- version: 1.0.1
9
+ - 2
10
+ version: 1.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Christoph Schiessl
@@ -15,8 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-05-28 00:00:00 +02:00
19
- default_executable:
18
+ date: 2011-05-29 00:00:00 Z
20
19
  dependencies:
21
20
  - !ruby/object:Gem::Dependency
22
21
  name: bundler
@@ -48,7 +47,7 @@ dependencies:
48
47
  version: "0.9"
49
48
  type: :development
50
49
  version_requirements: *id002
51
- description: Inspired by sentient_user Gem.
50
+ description: Replace methods like `current_account` in your controllers with globally accessible methods like `Account.current`.
52
51
  email: chs@proactive.cc
53
52
  executables: []
54
53
 
@@ -57,6 +56,7 @@ extensions: []
57
56
  extra_rdoc_files: []
58
57
 
59
58
  files:
59
+ - README.md
60
60
  - Rakefile
61
61
  - Gemfile
62
62
  - Gemfile.lock
@@ -64,7 +64,6 @@ files:
64
64
  - sentient_model.gemspec
65
65
  - spec/spec_helper.rb
66
66
  - spec/sentient_model_spec.rb
67
- has_rdoc: true
68
67
  homepage: http://github.com/bokmann/sentient_user
69
68
  licenses: []
70
69
 
@@ -98,7 +97,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
98
97
  requirements: []
99
98
 
100
99
  rubyforge_project:
101
- rubygems_version: 1.6.2
100
+ rubygems_version: 1.8.4
102
101
  signing_key:
103
102
  specification_version: 3
104
103
  summary: A trivial bit of common code