matic_accessor 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.txt +28 -0
- data/lib/matic_accessor.rb +29 -0
- data/test/test_matic_accessor.rb +0 -0
- metadata +58 -0
data/README.txt
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
Mongomatic::Plugins::Accessors
|
2
|
+
|
3
|
+
matic_accessor is a plugin for Mongomatic so you can use dot-notation to access the documents
|
4
|
+
attributes
|
5
|
+
|
6
|
+
Usage
|
7
|
+
|
8
|
+
require 'matic_accessor'
|
9
|
+
|
10
|
+
class Monkey < Mongomatic::Base
|
11
|
+
include Mongomatic::Plugins::Accessors
|
12
|
+
matic_accessor :name, :nickname
|
13
|
+
matic_reader :age
|
14
|
+
matic_writer :weight
|
15
|
+
end
|
16
|
+
|
17
|
+
m = Monkey.new
|
18
|
+
m.name = 'funny'
|
19
|
+
m.nickname = 'bob'
|
20
|
+
m[:age] = 13
|
21
|
+
m.weight = 100
|
22
|
+
m.insert
|
23
|
+
|
24
|
+
m = Monkey.find_one
|
25
|
+
m.name # funny
|
26
|
+
m.nickname # bob
|
27
|
+
m.age # 13
|
28
|
+
m[:weight] # 100
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Mongomatic
|
2
|
+
module Plugins
|
3
|
+
module Accessors
|
4
|
+
def self.included(base)
|
5
|
+
base.send(:extend, ClassMethods)
|
6
|
+
end
|
7
|
+
module ClassMethods
|
8
|
+
def matic_accessor(*attributes)
|
9
|
+
matic_reader(*attributes)
|
10
|
+
matic_writer(*attributes)
|
11
|
+
end
|
12
|
+
def matic_reader(*attributes)
|
13
|
+
attributes.each do |attribute|
|
14
|
+
define_method(:"#{attribute}") do
|
15
|
+
self[attribute]
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
def matic_writer(*attributes)
|
20
|
+
attributes.each do |attribute|
|
21
|
+
define_method(:"#{attribute}=") do |value|
|
22
|
+
self[attribute] = value
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
File without changes
|
metadata
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: matic_accessor
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.0.1
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Dusty Doris
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2011-05-19 00:00:00 -04:00
|
14
|
+
default_executable:
|
15
|
+
dependencies: []
|
16
|
+
|
17
|
+
description: Plugin for Mongomatic to provide dot-notation access to document attributes
|
18
|
+
email: github@dusty.name
|
19
|
+
executables: []
|
20
|
+
|
21
|
+
extensions: []
|
22
|
+
|
23
|
+
extra_rdoc_files:
|
24
|
+
- README.txt
|
25
|
+
files:
|
26
|
+
- README.txt
|
27
|
+
- lib/matic_accessor.rb
|
28
|
+
- test/test_matic_accessor.rb
|
29
|
+
has_rdoc: true
|
30
|
+
homepage: http://github.com/dusty/matic_accessor
|
31
|
+
licenses: []
|
32
|
+
|
33
|
+
post_install_message:
|
34
|
+
rdoc_options: []
|
35
|
+
|
36
|
+
require_paths:
|
37
|
+
- lib
|
38
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: "0"
|
44
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
45
|
+
none: false
|
46
|
+
requirements:
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: "0"
|
50
|
+
requirements: []
|
51
|
+
|
52
|
+
rubyforge_project: none
|
53
|
+
rubygems_version: 1.6.2
|
54
|
+
signing_key:
|
55
|
+
specification_version: 3
|
56
|
+
summary: Plugin for Mongomatic to provide dot-notation access to document attributes
|
57
|
+
test_files: []
|
58
|
+
|