Class: Card::Set::RequiredField

Inherits:
Object
  • Object
show all
Defined in:
card/lib/card/set/required_field.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parent_set, field, options = {}) ⇒ RequiredField

Returns a new instance of RequiredField.



6
7
8
9
10
# File 'card/lib/card/set/required_field.rb', line 6

def initialize parent_set, field, options={}
  @parent_set = parent_set
  @field = field
  @options = options
end

Instance Attribute Details

#fieldObject (readonly)

Returns the value of attribute field.



4
5
6
# File 'card/lib/card/set/required_field.rb', line 4

def field
  @field
end

#optionsObject (readonly)

Returns the value of attribute options.



4
5
6
# File 'card/lib/card/set/required_field.rb', line 4

def options
  @options
end

#parent_setObject (readonly)

Returns the value of attribute parent_set.



4
5
6
# File 'card/lib/card/set/required_field.rb', line 4

def parent_set
  @parent_set
end

Instance Method Details

#addObject



12
13
14
15
16
17
18
# File 'card/lib/card/set/required_field.rb', line 12

def add
  create_parent_event
  return unless field_events?

  define_field_test
  create_field_events
end

#field_event_name(action) ⇒ Object



24
25
26
27
# File 'card/lib/card/set/required_field.rb', line 24

def field_event_name action
  [field, "required_by", parent_set.underscored_name, "on", action]
    .join("__").to_sym
end

#parent_event_nameObject



20
21
22
# File 'card/lib/card/set/required_field.rb', line 20

def parent_event_name
  [parent_set.underscored_name, "requires_field", field].join("__").to_sym
end