Module: Card::Set::All::FetchHelper::ClassMethods

Defined in:
tmpsets/set/mod003-core/all/fetch_helper.rb

Instance Method Summary collapse

Instance Method Details

#controller_fetch(args) ⇒ Object

a fetch method to support the needs of the card controller. should be in Decko?



11
12
13
14
15
16
17
18
19
20
21
# File 'tmpsets/set/mod003-core/all/fetch_helper.rb', line 11

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

#safe_param(param) ⇒ Object



23
24
25
26
27
28
29
30
31
# File 'tmpsets/set/mod003-core/all/fetch_helper.rb', line 23

def safe_param param
  if param.respond_to? :to_unsafe_h
    # clone doesn't work for Parameters
    param.to_unsafe_h
  else
    # clone so that original params remain unaltered.  need deeper clone?
    (param || {}).clone
  end
end