Sha256: 6313b5fbe5a9796e694f382d499ad69e0e824c53353973a87b0c9c9b20b53a5e

Contents?: true

Size: 1.45 KB

Versions: 7

Compression:

Stored size: 1.45 KB

Contents

# -*- encoding : utf-8 -*-
class Card; module Set; class All
# Set: All cards (FetchHelper)
#
module FetchHelper;
extend Card::Set
def self.source_location; "/Users/ethan/dev/decko/gem/card/mod/core/set/all/fetch_helper.rb"; end
module ClassMethods
  # a fetch method to support the needs of the card controller.
  # should be in Decko?
  def controller_fetch args
    card_opts = controller_fetch_opts args
    if args[:action] == "create"
      # FIXME: we currently need a "new" card to catch duplicates
      # (otherwise save will just act like a normal update)
      # We may need a "#create" instance method to handle this checking?
      Card.new card_opts
    else
      standard_controller_fetch args, card_opts
    end
  end

  private

  def standard_controller_fetch args, card_opts
    mark = args[:mark] || card_opts[:name]
    card = Card.fetch mark, skip_modules: true,
                            look_in_trash: args[:look_in_trash],
                            new: card_opts
    card.assign_attributes card_opts if args[:assign] && card&.real?
    card&.include_set_modules
    card
  end

  def controller_fetch_opts args
    opts = Env.hash args[:card]
    opts[:type] ||= args[:type] if args[:type]
    # for /new/:type shortcut.  we should handle in routing and deprecate this
    opts[:name] ||= Card::Name.url_key_to_standard args[:mark]
    opts
  end
end
end;end;end;end;
# ~~ generated from /Users/ethan/dev/decko/gem/card/mod/core/set/all/fetch_helper.rb ~~

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
card-1.101.5 tmpsets/set/mod002-core/all/fetch_helper.rb
card-1.101.4 tmpsets/set/mod002-core/all/fetch_helper.rb
card-1.101.3 tmpsets/set/mod002-core/all/fetch_helper.rb
card-1.101.2 tmpsets/set/mod002-core/all/fetch_helper.rb
card-1.101.1 tmpsets/set/mod002-core/all/fetch_helper.rb
card-1.101.0 tmpsets/set/mod002-core/all/fetch_helper.rb
card-1.100.0 tmpsets/set/mod003-core/all/fetch_helper.rb