Class: Super::Form::FieldTranscript

Inherits:
Object
  • Object
show all
Defined in:
lib/super/form/field_transcript.rb

Overview

Holds a recording of a form field definition

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeFieldTranscript

Returns a new instance of FieldTranscript.



7
8
9
# File 'lib/super/form/field_transcript.rb', line 7

def initialize
  @super = false
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(new_method_name, *args, **kwargs) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/super/form/field_transcript.rb', line 24

def method_missing(new_method_name, *args, **kwargs)
  if @method_name.present?
    method_chain =
      if super?
        "super.#{@method_name}"
      else
        @method_name.to_s
      end

    raise Error::AlreadyTranscribed, "This instance already holds a transcription for: #{method_chain}"
  end

  @method_name = new_method_name
  @args = args
  @kwargs = kwargs
  @method_name
end

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args.



12
13
14
# File 'lib/super/form/field_transcript.rb', line 12

def args
  @args
end

#kwargsObject (readonly)

Returns the value of attribute kwargs.



13
14
15
# File 'lib/super/form/field_transcript.rb', line 13

def kwargs
  @kwargs
end

#method_nameObject (readonly)

Returns the value of attribute method_name.



11
12
13
# File 'lib/super/form/field_transcript.rb', line 11

def method_name
  @method_name
end

Instance Method Details

#superObject



15
16
17
18
# File 'lib/super/form/field_transcript.rb', line 15

def super
  @super = true
  self
end

#super?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/super/form/field_transcript.rb', line 20

def super?
  @super
end