permissible 0.0.1

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,5 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
5
+ *~
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in permissible.gemspec
4
+ gemspec
@@ -0,0 +1,2 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1,30 @@
1
+ module Permissible
2
+ def self.included(base)
3
+ base.field :list_type, :type => String, :default => "whitelist"
4
+ base.field :permission_ids, :type => Array, :default => []
5
+ end
6
+
7
+ def blacklist(*args)
8
+ self.list_type = "blacklist"
9
+ self.permission_ids = (self.permission_ids + args).compact if args
10
+ end
11
+
12
+ def whitelist(*args)
13
+ self.list_type = "whitelist"
14
+ self.permission_ids = (self.permission_ids + args).compact if args
15
+ end
16
+
17
+ def add_to_list(*ids)
18
+ self.permission_ids = (self.permission_ids + ids).compact if ids
19
+ end
20
+
21
+ def permissible?(user)
22
+ if self.list_type == "blacklist"
23
+ self.permission_ids.include?(user.id) ? false : true
24
+ elsif self.list_type == "whitelist"
25
+ self.permission_ids.include?(user.id) ? true : false
26
+ else
27
+ return nil
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,3 @@
1
+ module Permissible
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "permissible/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "permissible"
7
+ s.version = Permissible::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Abhishiv Saxena"]
10
+ s.email = ["abhishiv@gmail.com"]
11
+ s.homepage = ""
12
+ s.summary = %q{Instance level Permissions for mongoid}
13
+
14
+
15
+ s.rubyforge_project = "permissible"
16
+
17
+ s.files = `git ls-files`.split("\n")
18
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
+ s.require_paths = ["lib"]
21
+ end
metadata ADDED
@@ -0,0 +1,62 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: permissible
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.0.1
6
+ platform: ruby
7
+ authors:
8
+ - Abhishiv Saxena
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2011-03-05 00:00:00 +01:00
14
+ default_executable:
15
+ dependencies: []
16
+
17
+ description:
18
+ email:
19
+ - abhishiv@gmail.com
20
+ executables: []
21
+
22
+ extensions: []
23
+
24
+ extra_rdoc_files: []
25
+
26
+ files:
27
+ - .gitignore
28
+ - Gemfile
29
+ - Rakefile
30
+ - lib/permissible.rb
31
+ - lib/permissible/version.rb
32
+ - permissible.gemspec
33
+ has_rdoc: true
34
+ homepage: ""
35
+ licenses: []
36
+
37
+ post_install_message:
38
+ rdoc_options: []
39
+
40
+ require_paths:
41
+ - lib
42
+ required_ruby_version: !ruby/object:Gem::Requirement
43
+ none: false
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: "0"
48
+ required_rubygems_version: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: "0"
54
+ requirements: []
55
+
56
+ rubyforge_project: permissible
57
+ rubygems_version: 1.5.0
58
+ signing_key:
59
+ specification_version: 3
60
+ summary: Instance level Permissions for mongoid
61
+ test_files: []
62
+