setter 0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/setter/setter.rb +16 -0
- data/lib/setter/settings.rb +18 -0
- data/lib/setter/version.rb +3 -0
- data/lib/setter.rb +2 -0
- metadata +48 -0
@@ -0,0 +1,16 @@
|
|
1
|
+
module Setter
|
2
|
+
def set(receiver, setting=nil)
|
3
|
+
set_attributes(receiver) unless setting
|
4
|
+
set_attribute(receiver, setting) if setting
|
5
|
+
end
|
6
|
+
|
7
|
+
def set_attributes(receiver)
|
8
|
+
receiver.class.settings.each do |setting|
|
9
|
+
set_attribute receiver, setting
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def set_attribute(receiver, setting)
|
14
|
+
receiver.send :"#{setting}=", (send setting) if respond_to?(setting)
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Setter
|
2
|
+
module Settings
|
3
|
+
def self.included(base)
|
4
|
+
base.extend ClassMethods
|
5
|
+
end
|
6
|
+
|
7
|
+
module ClassMethods
|
8
|
+
def setting(setting)
|
9
|
+
attr_accessor setting
|
10
|
+
settings << setting
|
11
|
+
end
|
12
|
+
|
13
|
+
def settings
|
14
|
+
@settings ||= []
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/lib/setter.rb
ADDED
metadata
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: setter
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- We made this
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-10-30 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description:
|
15
|
+
email:
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- lib/setter/setter.rb
|
21
|
+
- lib/setter/settings.rb
|
22
|
+
- lib/setter/version.rb
|
23
|
+
- lib/setter.rb
|
24
|
+
homepage:
|
25
|
+
licenses: []
|
26
|
+
post_install_message:
|
27
|
+
rdoc_options: []
|
28
|
+
require_paths:
|
29
|
+
- lib
|
30
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
31
|
+
none: false
|
32
|
+
requirements:
|
33
|
+
- - ! '>='
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: 1.9.2
|
36
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
37
|
+
none: false
|
38
|
+
requirements:
|
39
|
+
- - ! '>='
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
42
|
+
requirements: []
|
43
|
+
rubyforge_project:
|
44
|
+
rubygems_version: 1.8.24
|
45
|
+
signing_key:
|
46
|
+
specification_version: 3
|
47
|
+
summary: Setter Library
|
48
|
+
test_files: []
|