prospecto 0.2.0 → 0.2.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.
@@ -1,7 +1,12 @@
1
1
  require "set"
2
2
 
3
3
  module Prospecto
4
+ # Optional base class for convenience when working with rails presenters.
4
5
  class PresenterView
6
+ # Initialize a new PresenterView instance accepting the provided arguments.
7
+ #
8
+ # @param [Hash] args key value pairs for what ever properties you declared
9
+ # on the class.
5
10
  def initialize(args={})
6
11
  args.each do |name, value|
7
12
  if respond_to? name
@@ -15,6 +20,7 @@ module Prospecto
15
20
  end
16
21
  end
17
22
 
23
+ # @private
18
24
  def method_missing(name, *args, &block)
19
25
  if property_name = self.class.__properties.find{|m| name.to_s.start_with? "#{m}_"}
20
26
  field_name = name.to_s.sub("#{property_name}_", "")
@@ -26,25 +32,23 @@ module Prospecto
26
32
  end
27
33
  end
28
34
 
35
+ # @private
29
36
  def __delegates
30
37
  @__delegates ||= Set.new
31
38
  end
32
39
 
33
40
  class << self
34
- # "Presents" means a member will be reflected out to the view. Use of presents should be
35
- # limited to very special cases.
36
- alias :presents :attr_reader
37
-
38
- def __properties
39
- @__properties ||= Set.new
40
- end
41
-
42
- def __delegates
43
- @__delegates ||= Set.new
41
+ # Instructs the class to create a publicly visible version of the value.
42
+ #
43
+ # @param [Symbols*] args name of the properties to accept. This will be used in the constructor.
44
+ def presents(*args)
45
+ attr_reader(*args)
44
46
  end
45
47
 
46
- # Accepts means the view uses the member internally, but it is not available
47
- # outside the class.
48
+ # Instructs the class to *accept* the value internally but not
49
+ # publish it.
50
+ #
51
+ # @param [Symbols*] args name of the properties to accept. This will be used in the constructor.
48
52
  def accepts(*args)
49
53
  args.each do |name|
50
54
  define_method name do
@@ -54,8 +58,10 @@ module Prospecto
54
58
  end
55
59
  end
56
60
 
57
- # Proxies means that the properties of the object can be accessed directly from this object
58
- # when prefixed with the object name. (ie: @view.user_full_name)
61
+ # Instructs the class that the properties of the object can be accessed directly from this object
62
+ # when prefixed with the object name. (ie: `@view.user_full_name`)
63
+ #
64
+ # @param [Symbols*] args name of the properties to accept. This will be used in the constructor.
59
65
  def proxies(*args)
60
66
  args.each do |name|
61
67
  __properties << name
@@ -63,12 +69,25 @@ module Prospecto
63
69
  accepts(*args)
64
70
  end
65
71
 
66
- # Decorates means that properties of the object will be available directly on the presenter.
72
+ # Instructs the class to proxy directly for this object like a true decorator. This is very similar
73
+ # to how something like [draper](https://github.com/jcasimir/draper) works.
74
+ #
75
+ # @param [Symbols*] args name of the properties to accept. This will be used in the constructor.
67
76
  def decorates(*args)
68
77
  args.each do |name|
69
78
  __delegates << name
70
79
  end
71
80
  end
81
+
82
+ # @private
83
+ def __properties
84
+ @__properties ||= Set.new
85
+ end
86
+
87
+ # @private
88
+ def __delegates
89
+ @__delegates ||= Set.new
90
+ end
72
91
  end
73
92
  end
74
93
  end
@@ -1,6 +1,7 @@
1
1
  require 'rails/railtie'
2
2
 
3
3
  module Prospecto
4
+ # @private
4
5
  class Railtie < Rails::Railtie
5
6
  initializer "prospecto.initialize" do |app|
6
7
  # Import the url helpers to allow resolving of URLs easily
@@ -1,3 +1,5 @@
1
+ # Main Prospecto namespace.
1
2
  module Prospecto
2
- VERSION = "0.2.0"
3
+ # The current Prospecto version.
4
+ VERSION = "0.2.1"
3
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prospecto
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-06-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
16
- requirement: &70296683085180 !ruby/object:Gem::Requirement
16
+ requirement: &70113014264460 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 3.1.0
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70296683085180
24
+ version_requirements: *70113014264460
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rspec
27
- requirement: &70296683083860 !ruby/object:Gem::Requirement
27
+ requirement: &70113014263760 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70296683083860
35
+ version_requirements: *70113014263760
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: pry
38
- requirement: &70296683082860 !ruby/object:Gem::Requirement
38
+ requirement: &70113014262840 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70296683082860
46
+ version_requirements: *70113014262840
47
47
  description: ''
48
48
  email:
49
49
  - bigjasonwebb@gmail.com
@@ -81,7 +81,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
81
81
  version: '0'
82
82
  segments:
83
83
  - 0
84
- hash: -977387351276312960
84
+ hash: -2544824161487180405
85
85
  required_rubygems_version: !ruby/object:Gem::Requirement
86
86
  none: false
87
87
  requirements:
@@ -90,7 +90,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
90
90
  version: '0'
91
91
  segments:
92
92
  - 0
93
- hash: -977387351276312960
93
+ hash: -2544824161487180405
94
94
  requirements: []
95
95
  rubyforge_project:
96
96
  rubygems_version: 1.8.10