Class: ToFactory::Parsing::NewSyntax

Inherits:
Syntax
  • Object
show all
Defined in:
lib/to_factory/parsing/new_syntax.rb

Instance Attribute Summary

Attributes inherited from Syntax

#contents

Instance Method Summary collapse

Methods inherited from Syntax

#factories, #factories_sexp, #initialize, #multiple_factories?, #name_from, #parse

Constructor Details

This class inherits a constructor from ToFactory::Parsing::Syntax

Instance Method Details

#header?Boolean

Returns:

  • (Boolean)


4
5
6
# File 'lib/to_factory/parsing/new_syntax.rb', line 4

def header?
  sexp[1][1][1] == :FactoryGirl rescue false
end

#parent_from(x) ⇒ Object



8
9
10
11
12
13
14
15
16
# File 'lib/to_factory/parsing/new_syntax.rb', line 8

def parent_from(x)
  # e.g.
  #s(:call, nil, :factory, s(:lit, :admin), s(:hash, s(:lit, :parent), s(:lit, :"to_factory/user")))
  x[1][4][2][1]
rescue  NoMethodError
  # e.g.
  #s(:call, nil, :factory, s(:lit, :"to_factory/user"))
  x[1][3][1]
end