Class: Soybean::Generators::ModelSpecGenerator

Inherits:
Object
  • Object
show all
Includes:
BaseGenerator
Defined in:
lib/soybean/generators/model_spec_generator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from BaseGenerator

#filename

Constructor Details

#initialize(model, spec_dir) ⇒ ModelSpecGenerator

Returns a new instance of ModelSpecGenerator.

Parameters:



9
10
11
12
# File 'lib/soybean/generators/model_spec_generator.rb', line 9

def initialize(model, spec_dir)
  @model, @spec_dir = model, spec_dir
  @name = model.name + '_spec'
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



6
7
8
# File 'lib/soybean/generators/model_spec_generator.rb', line 6

def name
  @name
end

Instance Method Details

#actionsObject



29
30
31
# File 'lib/soybean/generators/model_spec_generator.rb', line 29

def actions
  @actions ||= InterfaceBuilder.new(@model.wsdl, WSDL::SOAP::ClassNameCreator.new).actions
end

#class_nameObject



33
34
35
# File 'lib/soybean/generators/model_spec_generator.rb', line 33

def class_name
  @model.class_name
end

#dirObject



18
19
20
# File 'lib/soybean/generators/model_spec_generator.rb', line 18

def dir
  @spec_dir
end

#fullpath(basedir) ⇒ Object



14
15
16
# File 'lib/soybean/generators/model_spec_generator.rb', line 14

def fullpath(basedir)
  File.join(dir, filename)
end

#generateObject



22
23
24
25
26
27
# File 'lib/soybean/generators/model_spec_generator.rb', line 22

def generate
  source = File.expand_path("../templates/model_spec.rb", __FILE__)
  context = instance_eval('binding')
  content = ERB.new(::File.binread(source), nil, '-').result(context)
  content
end

#interface_nameObject



37
38
39
# File 'lib/soybean/generators/model_spec_generator.rb', line 37

def interface_name
  @model.interface_name
end