styler 0.1.0 → 0.1.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/README.rdoc CHANGED
@@ -8,3 +8,22 @@ This implements view-aware models, yet not. It's using the ProxyClass pattern.
8
8
 
9
9
  IRC:: #rango@irc.freenode.net
10
10
  Baretest:: http://github.com/apeiros/baretest
11
+
12
+ == Description
13
+
14
+ You use Styler::RangoMixin to render (or any other mixin). Call the render
15
+ method with (template, *model_instance_variables), and it will replace the
16
+ mentioned instance variables with Styles. You can use Style variables simply
17
+ by calling #to_s on them (HAML does that by default). The template path for the
18
+ Style is compiled by using
19
+
20
+ "#{__class__.to_s.downcase.gsub('::','/')}/#{@type}"
21
+
22
+ where @type is :default by default. Choose any other by calling #as(type).
23
+ If you want to add any context, pass them as a hash and they will be avaible
24
+ as instance variables.
25
+ If you need to delegate more methods to model/controller use #delegate and
26
+ #delegate_to_controller. There's a special #association delegater method
27
+ avaible which handles context passing and so on.
28
+
29
+ I'm not yet sure what happens if you use this for collections. Gotta try that.
@@ -0,0 +1,17 @@
1
+ require 'erector'
2
+ require 'styler'
3
+
4
+ class Styler::Widget < Erector::Widget
5
+ end
6
+
7
+ module Styler
8
+ module ErectorMixin
9
+ def render(klass)
10
+ @__controller = self
11
+ models.each {|name|
12
+ instance_variable_set("@#{name}",::Styler.new_style_for(instance_variable_get("@#{name}")))
13
+ }
14
+ end
15
+ end
16
+ end
17
+
@@ -2,9 +2,8 @@ require 'rango/mixins/rendering'
2
2
  require 'styler'
3
3
  module Styler
4
4
  module Style
5
- module InstanceMethods
6
- include Rango::ImplicitRendering
7
- end
5
+ include Rango::Helpers
6
+ include Rango::ImplicitRendering
8
7
  end
9
8
  end
10
9
 
@@ -16,7 +15,7 @@ module Styler
16
15
  models.each {|name|
17
16
  instance_variable_set("@#{name}",::Styler.new_style_for(instance_variable_get("@#{name}")))
18
17
  }
19
- super
18
+ super(template)
20
19
  end
21
20
  end
22
21
  end
data/lib/styler/style.rb CHANGED
@@ -29,6 +29,11 @@ module Styler
29
29
  end
30
30
 
31
31
  def style_for(model)
32
+ model.instance_methods.each do |method|
33
+ unless method_defined? method
34
+ define_method(method) {|*args| @model.send(method, *args)}
35
+ end
36
+ end
32
37
  Styler::STYLES.merge!({model => self})
33
38
  end
34
39
  end
data/test/setup.rb CHANGED
@@ -32,7 +32,6 @@ module Style
32
32
  style_for Model::Foo
33
33
  association :foo
34
34
  association :fooz
35
- delegate :hello
36
35
  def context; {}; end
37
36
  end
38
37
  end
metadata CHANGED
@@ -5,15 +5,15 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 0
9
- version: 0.1.0
8
+ - 1
9
+ version: 0.1.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Simon Hafner aka Tass
13
13
  autorequire:
14
14
  bindir: bin
15
15
  cert_chain:
16
- date: 2010-02-28 00:00:00 +01:00
16
+ date: 2010-03-14 00:00:00 +01:00
17
17
  default_executable:
18
18
  dependencies: []
19
19
 
@@ -26,6 +26,7 @@ extensions: []
26
26
  extra_rdoc_files: []
27
27
 
28
28
  files:
29
+ - lib/styler/mixins/erector.rb
29
30
  - lib/styler/mixins/rango.rb
30
31
  - lib/styler/style.rb
31
32
  - lib/styler.rb