instant_dsl 0.2.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/README CHANGED
@@ -16,11 +16,7 @@ require 'instant_dsl'
16
16
 
17
17
  PageDSL = InstantDSL[:title, :items]
18
18
 
19
- class Page
20
- include PageDSL
21
- end
22
-
23
- page = Page.new
19
+ page = PageDSL.new
24
20
 
25
21
  page.instance_eval do
26
22
  title 'hey'
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.1
1
+ 0.3.0
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{instant_dsl}
8
- s.version = "0.2.1"
8
+ s.version = "0.3.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["jbe"]
@@ -1,18 +1,24 @@
1
1
 
2
2
  module InstantDSL
3
- def self.[](*actions)
4
- kls = Module.new
3
+ def self.new(*actions)
4
+ mod = Module.new
5
5
 
6
- kls.send :attr_accessor, :dsl_values
6
+ mod.send :attr_accessor, :dsl_values
7
7
 
8
8
  actions.each do |act|
9
- kls.send :define_method, act do |*args|
9
+ mod.send :define_method, act do |*args|
10
10
  @dsl_values ||= {}
11
11
  @dsl_values[act] ||= []
12
12
  @dsl_values[act] += args
13
13
  self
14
14
  end
15
15
  end
16
+ mod
17
+ end
18
+
19
+ def self.[](*actions)
20
+ kls = Class.new
21
+ kls.send :include, self.new(*actions)
16
22
  kls
17
23
  end
18
24
  end
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 2
8
- - 1
9
- version: 0.2.1
7
+ - 3
8
+ - 0
9
+ version: 0.3.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - jbe