Class: ActiveScaffold::DataStructures::ActionLink
- Defined in:
- lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/data_structures/action_link.rb
Instance Attribute Summary collapse
-
#action ⇒ Object
the action-path for this link.
- #confirm ⇒ Object
-
#controller ⇒ Object
the controller for this action link.
-
#crud_type ⇒ Object
the crud type of the (eventual?) action.
- #dhtml_confirm ⇒ Object
-
#html_options ⇒ Object
html options for the link.
- #label ⇒ Object
-
#method ⇒ Object
the RESTful method.
-
#parameters ⇒ Object
a hash of request parameters.
- #position ⇒ Object
- #security_method ⇒ Object
-
#type ⇒ Object
what type of link this is.
Instance Method Summary collapse
- #confirm? ⇒ Boolean
- #dhtml_confirm? ⇒ Boolean
-
#initialize(action, options = {}) ⇒ ActionLink
constructor
provides a quick way to set any property of the object from a hash.
-
#inline=(val) ⇒ Object
an “inline” link is inserted into the existing page exclusive with popup? and page?.
- #inline? ⇒ Boolean
-
#page=(val) ⇒ Object
a “page” link displays by reloading the current page exclusive with inline? and popup?.
- #page? ⇒ Boolean
-
#popup=(val) ⇒ Object
a “popup” link displays in a separate (browser?) window.
- #popup? ⇒ Boolean
- #security_method_set? ⇒ Boolean
Constructor Details
#initialize(action, options = {}) ⇒ ActionLink
provides a quick way to set any property of the object from a hash
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/data_structures/action_link.rb', line 4 def initialize(action, = {}) # set defaults self.action = action.to_s self.label = action self.confirm = false self.type = :table self.inline = true self.method = :get self.crud_type = :destroy if [:destroy].include?(action.to_sym) self.crud_type = :create if [:create, :new].include?(action.to_sym) self.crud_type = :update if [:edit, :update].include?(action.to_sym) self.crud_type ||= :read self. = {} # apply quick properties .each_pair do |k, v| setter = "#{k}=" self.send(setter, v) if self.respond_to? setter end end |
Instance Attribute Details
#action ⇒ Object
the action-path for this link. what page to request? this is required!
26 27 28 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/data_structures/action_link.rb', line 26 def action @action end |
#confirm ⇒ Object
45 46 47 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/data_structures/action_link.rb', line 45 def confirm @confirm.is_a?(String) ? as_(@confirm) : @confirm end |
#controller ⇒ Object
the controller for this action link. if nil, the current controller should be assumed.
29 30 31 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/data_structures/action_link.rb', line 29 def controller @controller end |
#crud_type ⇒ Object
the crud type of the (eventual?) action. different than :method, because this crud action may not be imminent. this is used to determine record-level authorization (e.g. record.authorized_for?(:action => link.crud_type). options are :create, :read, :update, and :destroy
75 76 77 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/data_structures/action_link.rb', line 75 def crud_type @crud_type end |
#dhtml_confirm ⇒ Object
54 55 56 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/data_structures/action_link.rb', line 54 def dhtml_confirm @dhtml_confirm end |
#html_options ⇒ Object
html options for the link
138 139 140 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/data_structures/action_link.rb', line 138 def @html_options end |
#label ⇒ Object
39 40 41 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/data_structures/action_link.rb', line 39 def label @label.is_a?(Symbol) ? as_(@label) : @label end |
#method ⇒ Object
the RESTful method
35 36 37 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/data_structures/action_link.rb', line 35 def method @method end |
#parameters ⇒ Object
a hash of request parameters
32 33 34 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/data_structures/action_link.rb', line 32 def parameters @parameters end |
#position ⇒ Object
128 129 130 131 132 133 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/data_structures/action_link.rb', line 128 def position return @position unless @position.nil? or @position == true return :replace if self.type == :record return :top if self.type == :table raise "what should the default position be for #{self.type}?" end |
#security_method ⇒ Object
64 65 66 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/data_structures/action_link.rb', line 64 def security_method @security_method || "#{self.label.underscore.downcase.gsub(/ /, '_')}_authorized?" end |
#type ⇒ Object
what type of link this is. currently supported values are :table and :record.
136 137 138 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/data_structures/action_link.rb', line 136 def type @type end |
Instance Method Details
#confirm? ⇒ Boolean
48 49 50 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/data_structures/action_link.rb', line 48 def confirm? @confirm ? true : false end |
#dhtml_confirm? ⇒ Boolean
57 58 59 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/data_structures/action_link.rb', line 57 def dhtml_confirm? @dhtml_confirm end |
#inline=(val) ⇒ Object
an “inline” link is inserted into the existing page exclusive with popup? and page?
79 80 81 82 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/data_structures/action_link.rb', line 79 def inline=(val) @inline = (val == true) self.popup = self.page = false if @inline end |
#inline? ⇒ Boolean
83 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/data_structures/action_link.rb', line 83 def inline?; @inline end |
#page=(val) ⇒ Object
a “page” link displays by reloading the current page exclusive with inline? and popup?
101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/data_structures/action_link.rb', line 101 def page=(val) @page = (val == true) if @page self.inline = self.popup = false # when :method is defined, ActionView adds an onclick to use a form ... # so it's best to just empty out :method whenever possible. # we only ever need to know @method = :get for things that default to POST. # the only things that default to POST are forms and ajax calls. # when @page = true, we don't use ajax. self.method = nil if method == :get end end |
#page? ⇒ Boolean
114 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/data_structures/action_link.rb', line 114 def page?; @page end |
#popup=(val) ⇒ Object
a “popup” link displays in a separate (browser?) window. this will eventually take arguments. exclusive with inline? and page?
87 88 89 90 91 92 93 94 95 96 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/data_structures/action_link.rb', line 87 def popup=(val) @popup = (val == true) if @popup self.inline = self.page = false # the :method parameter doesn't mix with the :popup parameter # when/if we start using DHTML popups, we can bring :method back self.method = nil end end |
#popup? ⇒ Boolean
97 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/data_structures/action_link.rb', line 97 def popup?; @popup end |
#security_method_set? ⇒ Boolean
68 69 70 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/data_structures/action_link.rb', line 68 def security_method_set? !!@security_method end |