Class: RailsDecorateFactory::MetaClass
- Inherits:
-
Object
- Object
- RailsDecorateFactory::MetaClass
show all
- Defined in:
- lib/rails_decorate_factory/meta_class.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(request) ⇒ MetaClass
Returns a new instance of MetaClass.
28
29
30
|
# File 'lib/rails_decorate_factory/meta_class.rb', line 28
def initialize( request )
@request = request
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args) ⇒ Object
76
77
78
79
80
81
82
83
|
# File 'lib/rails_decorate_factory/meta_class.rb', line 76
def method_missing( method_name , *args )
if /\Acurrent_([a-z_]+)\Z/ =~ method_name.to_s
if args.blank?
current_position( $1 )
end
end
return super( method_name , args )
end
|
Instance Attribute Details
#request ⇒ Object
Returns the value of attribute request.
32
33
34
|
# File 'lib/rails_decorate_factory/meta_class.rb', line 32
def request
@request
end
|
Class Method Details
.initialize_in_rails_app ⇒ Object
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/rails_decorate_factory/meta_class.rb', line 3
def self.initialize_in_rails_app
self.class_eval do
@@action_view_base = ::ActionView::Base.new
@@action_view_helpers = ::ActionView::Helpers::UrlHelper
@@action_controller_base = ::ActionController::Base.new
@@url_helpers = ::Rails.application.routes.url_helpers
@@application_controller_helper = ::ApplicationController.helpers
end
end
|
Instance Method Details
#current_host ⇒ Object
38
39
40
|
# File 'lib/rails_decorate_factory/meta_class.rb', line 38
def current_host
@request.host
end
|
#fullpath ⇒ Object
58
59
60
|
# File 'lib/rails_decorate_factory/meta_class.rb', line 58
def fullpath
@request.fullpath
end
|
#path ⇒ Object
34
35
36
|
# File 'lib/rails_decorate_factory/meta_class.rb', line 34
def path
recognize_path( @request.referer )
end
|
#recognize_path(url) ⇒ Object
62
63
64
|
# File 'lib/rails_decorate_factory/meta_class.rb', line 62
def recognize_path( url )
::Rails.application.routes.recognize_path( url )
end
|