Class: Model

Inherits:
Object
  • Object
show all
Defined in:
lib/relationships/model.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ Model

Returns a new instance of Model.



8
9
10
11
# File 'lib/relationships/model.rb', line 8

def initialize(args = {})
  @file_path = args[:file]
  @file_contents = File.read file_path if file_path
end

Instance Attribute Details

#file_contentsObject

Returns the value of attribute file_contents.



2
3
4
# File 'lib/relationships/model.rb', line 2

def file_contents
  @file_contents
end

#file_pathObject

Returns the value of attribute file_path.



2
3
4
# File 'lib/relationships/model.rb', line 2

def file_path
  @file_path
end

Class Method Details

.from_file(file) ⇒ Object



4
5
6
# File 'lib/relationships/model.rb', line 4

def self.from_file(file)
  Model.new file: file
end

Instance Method Details

#class_nameObject



21
22
23
# File 'lib/relationships/model.rb', line 21

def class_name
  file_name[/\w+/].camelize
end

#file_nameObject



17
18
19
# File 'lib/relationships/model.rb', line 17

def file_name
  file_path[/\w+\.rb/]
end

#relationshipsObject



13
14
15
# File 'lib/relationships/model.rb', line 13

def relationships
  @relationships ||= extract_relationships
end