Module: Card::Set::All::TrackedAttributes

Extended by:
Card::Set
Defined in:
tmpsets/set/mod001-01_core/all/tracked_attributes.rb

Instance Method Summary collapse

Methods included from Card::Set

abstract_set?, all_set?, card_accessor, card_reader, card_writer, clean_empty_module_from_hash, clean_empty_modules, define_active_job, define_event_method, define_event_perform_later_method, define_on_format, ensure_set, event, extended, format, process_base_module_list, process_base_modules, register_set, register_set_format, shortname, view, write_tmp_file

Instance Method Details

#assign_attributes(args = {}) ⇒ Object

fixme -this is called by both initialize and update_attributes. really should be optimized for new!



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'tmpsets/set/mod001-01_core/all/tracked_attributes.rb', line 4

def assign_attributes args={}
  if args
    args = args.stringify_keys

    @set_specific = {}
    Card.set_specific_attributes.each do |key|
      @set_specific[key] = args.delete(key) if args[key]
    end

    if newtype = args.delete('type')
      args['type_id'] = Card.fetch_id newtype
    end
    @subcards = extract_subcard_args! args
    reset_patterns
  end
  params = ActionController::Parameters.new(args)
  params.permit!
  super params
end

#assign_set_specific_attributesObject



24
25
26
27
28
29
30
# File 'tmpsets/set/mod001-01_core/all/tracked_attributes.rb', line 24

def assign_set_specific_attributes
  if @set_specific && @set_specific.present?
    @set_specific.each_pair do |name, value|
      self.send "#{name}=", value
    end
  end
end

#extract_subcard_args!(args = {}) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
# File 'tmpsets/set/mod001-01_core/all/tracked_attributes.rb', line 32

def extract_subcard_args! args={}
  extracted_subcards = args.delete('subcards') || {}
  args.keys.each do |key|
    if key =~ /^\+/
      val = args.delete key
      val = { 'content' => val } if String === val
      extracted_subcards[key] = val
    end
  end
  extracted_subcards
end