Class: ActivePresenter::Base

Inherits:
Object
  • Object
show all
Includes:
ActionController::UrlWriter, ActionView::Helpers::ActiveRecordHelper, ActionView::Helpers::AssetTagHelper, ActionView::Helpers::BenchmarkHelper, ActionView::Helpers::CacheHelper, ActionView::Helpers::DateHelper, ActionView::Helpers::FormHelper, ActionView::Helpers::FormOptionsHelper, ActionView::Helpers::FormTagHelper, ActionView::Helpers::JavaScriptHelper, ActionView::Helpers::JavaScriptMacrosHelper, ActionView::Helpers::NumberHelper, ActionView::Helpers::PaginationHelper, ActionView::Helpers::PrototypeHelper, ActionView::Helpers::ScriptaculousHelper, ActionView::Helpers::TagHelper, ActionView::Helpers::TextHelper, ActionView::Helpers::UrlHelper
Defined in:
lib/active_presenter_base.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source, options = {}) ⇒ Base

Returns a new instance of Base.



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/active_presenter_base.rb', line 36

def initialize(source, options = {})
  # running_time("source = #{source.class.to_s.underscore}; #{source}") do
    self.model_underscore = source.class.to_s.underscore
    self.model_camelcase = source.class.to_s
    eval %{alias :#{self.model_underscore} :model}
    @model = source
    self.options = options || {}
    # running_time("if source.is_a? ActiveRecord::Base") do
    #           if source.is_a? ActiveRecord::Base
    #             if source.is_restful?
    #               running_time("if source.is_restful?") do
    #                 running_time("build_common_ar_resource_methods") do
    #                   build_common_ar_resource_methods
    #                 end
    #                 running_time("build_ar_resource_methods") do
    #                   build_ar_resource_methods
    #                 end
    #               end
    #             else
    #               #build_ar_non_resource_methods
    #             end
    #           end
    #         end
  # end
end

Instance Attribute Details

#model_camelcaseObject

> DebateSide



34
35
36
# File 'lib/active_presenter_base.rb', line 34

def model_camelcase
  @model_camelcase
end

#model_underscoreObject

> debate_side



33
34
35
# File 'lib/active_presenter_base.rb', line 33

def model_underscore
  @model_underscore
end

#optionsObject

Returns the value of attribute options.



32
33
34
# File 'lib/active_presenter_base.rb', line 32

def options
  @options
end

Instance Method Details

#create_pathObject



111
112
113
114
115
# File 'lib/active_presenter_base.rb', line 111

def create_path
  ivar_cache do
    eval "#{self.plural}_path#{self.nested_resource_path_string}"
  end
end


89
90
91
# File 'lib/active_presenter_base.rb', line 89

def destroy_link_options
  {:confirm => 'Are you sure?', :method => :delete}
end

#destroy_pathObject



129
130
131
132
133
# File 'lib/active_presenter_base.rb', line 129

def destroy_path
  ivar_cache do
    eval "#{self.singular}_path#{self.nested_resource_path_string(true)}"
  end
end

#edit_pathObject



117
118
119
120
121
# File 'lib/active_presenter_base.rb', line 117

def edit_path
  ivar_cache do
    eval "edit_#{self.singular}_path#{self.nested_resource_path_string(true)}"
  end
end

#index_pathObject



93
94
95
96
97
# File 'lib/active_presenter_base.rb', line 93

def index_path
  ivar_cache do
    eval "#{self.plural}_path#{self.nested_resource_path_string}"
  end
end

#modelObject



62
63
64
# File 'lib/active_presenter_base.rb', line 62

def model
  @model
end

#new_pathObject



105
106
107
108
109
# File 'lib/active_presenter_base.rb', line 105

def new_path
  ivar_cache do
    eval "new_#{self.singular}_path#{self.nested_resource_path_string}"
  end
end

#show_pathObject



99
100
101
102
103
# File 'lib/active_presenter_base.rb', line 99

def show_path
  ivar_cache do
    eval "#{self.singular}_path#{self.nested_resource_path_string(true)}"
  end
end

#update_pathObject



123
124
125
126
127
# File 'lib/active_presenter_base.rb', line 123

def update_path
  ivar_cache do
    eval "#{self.singular}_path#{self.nested_resource_path_string(true)}"
  end
end