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::NumberHelper, 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



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

def create_path
  ivar_cache do
    eval(path_builder(:type => :plural))
  end
end


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

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

#destroy_pathObject



134
135
136
137
138
# File 'lib/active_presenter_base.rb', line 134

def destroy_path
  ivar_cache do
    eval(path_builder(:include_self => true))
  end
end

#edit_pathObject



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

def edit_path
  ivar_cache do
    eval(path_builder(:prefix => "edit", :include_self => true))
  end
end

#index_pathObject



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

def index_path
  ivar_cache do
    eval(path_builder(:type => :plural))
  end
end

#modelObject



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

def model
  @model
end

#new_pathObject



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

def new_path
  ivar_cache do
    eval(path_builder(:prefix => "new"))
  end
end

#protect_against_forgery?Boolean

TODO: FIX THIS!!!

Returns:

  • (Boolean)


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

def protect_against_forgery?
  false
end

#show_pathObject



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

def show_path
  ivar_cache do
    eval(path_builder(:include_self => true))
  end
end

#update_pathObject



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

def update_path
  ivar_cache do
    eval(path_builder(:include_self => true))
  end
end