bsm_models 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,15 @@
1
+ module Bsm::Model::Abstract
2
+ extend ActiveSupport::Concern
3
+
4
+ included do
5
+ validate :must_not_be_abstract
6
+
7
+ class_eval <<-END_EVAL
8
+ def must_not_be_abstract
9
+ errors.add :base, :abstract unless self.class < ::#{self.name}
10
+ end
11
+ END_EVAL
12
+ protected :must_not_be_abstract
13
+ end
14
+
15
+ end
@@ -0,0 +1,12 @@
1
+ module Bsm::Model::Deletable
2
+ extend ActiveSupport::Concern
3
+
4
+ included do
5
+ before_destroy :deletable?
6
+ end
7
+
8
+ def deletable?
9
+ not_implemented
10
+ end
11
+
12
+ end
@@ -0,0 +1,22 @@
1
+ module Bsm::Model::Editable
2
+ extend ActiveSupport::Concern
3
+
4
+ included do
5
+ validate :must_be_editable, :on => :update
6
+ end
7
+
8
+ def editable?
9
+ not_implemented
10
+ end
11
+
12
+ def immutable?
13
+ !editable?
14
+ end
15
+
16
+ protected
17
+
18
+ def must_be_editable
19
+ errors.add :base, :immutable if immutable?
20
+ end
21
+
22
+ end
@@ -0,0 +1,6 @@
1
+ en:
2
+ activerecord:
3
+ errors:
4
+ messages:
5
+ abstract: "Record is abstract"
6
+ immutable: "Record cannot be updated"
data/lib/bsm_models.rb ADDED
@@ -0,0 +1,14 @@
1
+ require "rails"
2
+
3
+ module Bsm
4
+ module Model
5
+ autoload :Abstract, 'bsm/model/abstract'
6
+ autoload :Editable, 'bsm/model/editable'
7
+ autoload :Deletable, 'bsm/model/deletable'
8
+ end
9
+
10
+ class Railtie < ::Rails::Railtie
11
+ require 'active_support/i18n'
12
+ I18n.load_path << File.expand_path('../bsm/model/locale/en.yml', __FILE__)
13
+ end
14
+ end
metadata ADDED
@@ -0,0 +1,102 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bsm_models
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 0
10
+ version: 0.1.0
11
+ platform: ruby
12
+ authors:
13
+ - Dimitrij Denissenko
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-08-31 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: abstract
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ hash: 3
29
+ segments:
30
+ - 0
31
+ version: "0"
32
+ type: :runtime
33
+ version_requirements: *id001
34
+ - !ruby/object:Gem::Dependency
35
+ name: rails
36
+ prerelease: false
37
+ requirement: &id002 !ruby/object:Gem::Requirement
38
+ none: false
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ hash: 7
43
+ segments:
44
+ - 3
45
+ - 0
46
+ - 0
47
+ version: 3.0.0
48
+ type: :runtime
49
+ version_requirements: *id002
50
+ description: ""
51
+ email: dimitrij@blacksquaremedia.com
52
+ executables: []
53
+
54
+ extensions: []
55
+
56
+ extra_rdoc_files: []
57
+
58
+ files:
59
+ - lib/bsm/model/abstract.rb
60
+ - lib/bsm/model/locale/en.yml
61
+ - lib/bsm/model/deletable.rb
62
+ - lib/bsm/model/editable.rb
63
+ - lib/bsm_models.rb
64
+ homepage: https://github.com/bsm/models
65
+ licenses: []
66
+
67
+ post_install_message:
68
+ rdoc_options: []
69
+
70
+ require_paths:
71
+ - lib
72
+ required_ruby_version: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ hash: 57
78
+ segments:
79
+ - 1
80
+ - 8
81
+ - 7
82
+ version: 1.8.7
83
+ required_rubygems_version: !ruby/object:Gem::Requirement
84
+ none: false
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ hash: 23
89
+ segments:
90
+ - 1
91
+ - 3
92
+ - 6
93
+ version: 1.3.6
94
+ requirements: []
95
+
96
+ rubyforge_project:
97
+ rubygems_version: 1.8.5
98
+ signing_key:
99
+ specification_version: 3
100
+ summary: BSM's very custom model extensions
101
+ test_files: []
102
+