immutable_model 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.
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in immutable_model.gemspec
4
+ gemspec
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,20 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "immutable_model/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "immutable_model"
7
+ s.version = ImmutableModel::VERSION
8
+ s.authors = ["unnitallman"]
9
+ s.email = ["unni.tallman@gmail.com"]
10
+ s.homepage = ""
11
+ s.summary = %q{Make specific attributes of an ActiveRecord model immutable}
12
+ s.description = %q{Make specific attributes of an ActiveRecord model immutable}
13
+
14
+ s.rubyforge_project = "immutable_model"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
20
+ end
@@ -0,0 +1,3 @@
1
+ module ImmutableModel
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,18 @@
1
+ require "immutable_model/version"
2
+
3
+ module ImmutableModel
4
+ def immutable(attr_name)
5
+ define_method "#{attr_name}=" do |new_value|
6
+ if read_attribute(attr_name).nil?
7
+ write_attribute(attr_name, new_value)
8
+ else
9
+ raise(RuntimeError, "#{attr_name} is an immutable attribute. You can't change it after it has been set")
10
+ end
11
+ end
12
+ end
13
+ end
14
+
15
+ if defined?(ActiveRecord::Base)
16
+ ActiveRecord::Base.extend ImmutableModel
17
+ end
18
+
metadata ADDED
@@ -0,0 +1,61 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: immutable_model
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - unnitallman
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2011-10-27 00:00:00 +05:30
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: Make specific attributes of an ActiveRecord model immutable
17
+ email:
18
+ - unni.tallman@gmail.com
19
+ executables: []
20
+
21
+ extensions: []
22
+
23
+ extra_rdoc_files: []
24
+
25
+ files:
26
+ - .gitignore
27
+ - Gemfile
28
+ - Rakefile
29
+ - immutable_model.gemspec
30
+ - lib/immutable_model.rb
31
+ - lib/immutable_model/version.rb
32
+ has_rdoc: true
33
+ homepage: ""
34
+ licenses: []
35
+
36
+ post_install_message:
37
+ rdoc_options: []
38
+
39
+ require_paths:
40
+ - lib
41
+ required_ruby_version: !ruby/object:Gem::Requirement
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ version: "0"
46
+ version:
47
+ required_rubygems_version: !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - ">="
50
+ - !ruby/object:Gem::Version
51
+ version: "0"
52
+ version:
53
+ requirements: []
54
+
55
+ rubyforge_project: immutable_model
56
+ rubygems_version: 1.3.5
57
+ signing_key:
58
+ specification_version: 3
59
+ summary: Make specific attributes of an ActiveRecord model immutable
60
+ test_files: []
61
+