Module: Card::Set::Trait

Included in:
Card::Set
Defined in:
card/lib/card/set/trait.rb

Overview

ActiveCard support: accessing plus cards as attributes

Instance Method Summary collapse

Instance Method Details

#card_accessor(*args) ⇒ Object



5
6
7
8
# File 'card/lib/card/set/trait.rb', line 5

def card_accessor *args
  options = args.extract_options!
  add_traits args, options.merge(reader: true, writer: true)
end

#card_reader(*args) ⇒ Object



10
11
12
13
# File 'card/lib/card/set/trait.rb', line 10

def card_reader *args
  options = args.extract_options!
  add_traits args, options.merge(reader: true)
end

#card_writer(*args) ⇒ Object



15
16
17
18
# File 'card/lib/card/set/trait.rb', line 15

def card_writer *args
  options = args.extract_options!
  add_traits args, options.merge(writer: true)
end

#require_field(*fields) ⇒ Object



20
21
22
23
24
25
# File 'card/lib/card/set/trait.rb', line 20

def require_field *fields
  options = fields.last.is_a?(Hash) ? fields.pop : {}
  fields.each do |field|
    Card::Set::RequiredField.new(self, field, options).add
  end
end