Skip to content

Commit

Permalink
don't use cow proxy on action links
Browse files Browse the repository at this point in the history
we won't support changing action links per request, add all needed action links and then use ignore_method to hide links when they shouldn't be there
  • Loading branch information
scambra committed Oct 23, 2024
1 parent 17c2d08 commit 3f1d761
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/active_scaffold/config/core.rb
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ def columns
end

def action_links
@action_links ||= CowProxy.wrap(@conf.action_links)
@conf.action_links
end

def model
Expand Down
4 changes: 3 additions & 1 deletion lib/active_scaffold/data_structures/action_links.rb
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ def subgroup(name, label = nil)
end

if group.nil?
group = ActiveScaffold::DataStructures::ActionLinks.new
raise RuntimeError, "Can't add new subgroup '#{name}', links are frozen" if frozen?
group = ActiveScaffold::DataStructures::ActionLinks.new(name)
group.label = label || name
group.default_type = self.name == :root ? (name.to_sym if %w[member collection].include?(name.to_s)) : default_type
add_to_set group
Expand All @@ -152,6 +153,7 @@ def label(record)

def method_missing(name, *args, &block)
return super if name.match?(/[!?]$/)
return subgroup(name.to_sym, args.first, &block) if frozen?
class_eval <<-METHOD, __FILE__, __LINE__ + 1
def #{name}(label = nil) # rubocop:disable Style/CommentedKeyword
@#{name} ||= subgroup('#{name}'.to_sym, label)
Expand Down

0 comments on commit 3f1d761

Please sign in to comment.