Class: AttrFile

Inherits:
Object
  • Object
show all
Defined in:
lib/active_csv/attr_file.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(_name) ⇒ AttrFile

Returns a new instance of AttrFile.



4
5
6
# File 'lib/active_csv/attr_file.rb', line 4

def initialize(_name)
	@name = _name
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



2
3
4
# File 'lib/active_csv/attr_file.rb', line 2

def name
  @name
end

Instance Method Details

#fields(model_name) ⇒ Object



7
8
9
10
11
# File 'lib/active_csv/attr_file.rb', line 7

def fields(model_name)
	# The sequency of the attributes is always the same as in the yaml file.
	model_fields = YAML.load_file(@name)
	model_fields[model_name].split(', ') #Array
end