Class: Adva::Static::Import::Format::Base
- Inherits:
-
Object
- Object
- Adva::Static::Import::Format::Base
- Defined in:
- lib/adva/static/import/format.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #define_attribute(target, name) ⇒ Object
- #define_attribute?(target, name) ⇒ Boolean
-
#initialize(path) ⇒ Base
constructor
A new instance of Base.
- #load(target) ⇒ Object
Constructor Details
#initialize(path) ⇒ Base
Returns a new instance of Base.
13 14 15 |
# File 'lib/adva/static/import/format.rb', line 13 def initialize(path) @path = path end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
11 12 13 |
# File 'lib/adva/static/import/format.rb', line 11 def path @path end |
Instance Method Details
#define_attribute(target, name) ⇒ Object
28 29 30 31 32 |
# File 'lib/adva/static/import/format.rb', line 28 def define_attribute(target, name) target.attribute_names << name target.attribute_names.uniq! target.class.send(:attr_reader, name) unless target.respond_to?(name) end |
#define_attribute?(target, name) ⇒ Boolean
24 25 26 |
# File 'lib/adva/static/import/format.rb', line 24 def define_attribute?(target, name) !target.attribute_name?(name) && target.column_name?(name) end |
#load(target) ⇒ Object
17 18 19 20 21 22 |
# File 'lib/adva/static/import/format.rb', line 17 def load(target) data.each do |name, value| define_attribute(target, name) if define_attribute?(target, name) target.instance_variable_set(:"@#{name}", value) end if data.is_a?(Hash) end |