Module: DirModel::Import

Extended by:
ActiveSupport::Concern
Defined in:
lib/dir_model/import.rb,
lib/dir_model/import/dir.rb,
lib/dir_model/import/path.rb

Defined Under Namespace

Modules: ClassMethods Classes: Dir, Path

Instance Attribute Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &block) ⇒ Object



20
21
22
23
24
25
# File 'lib/dir_model/import.rb', line 20

def method_missing(name, *args, &block)
  load
  @_match[name]
rescue
  super
end

Instance Attribute Details

#contextObject (readonly)

Returns the value of attribute context.



5
6
7
# File 'lib/dir_model/import.rb', line 5

def context
  @context
end

#foreign_valueObject (readonly)

Returns the value of attribute foreign_value.



5
6
7
# File 'lib/dir_model/import.rb', line 5

def foreign_value
  @foreign_value
end

#indexObject (readonly)

Returns the value of attribute index.



5
6
7
# File 'lib/dir_model/import.rb', line 5

def index
  @index
end

#previousObject (readonly)

Returns the value of attribute previous.



5
6
7
# File 'lib/dir_model/import.rb', line 5

def previous
  @previous
end

#source_pathObject (readonly)

Returns the value of attribute source_path.



5
6
7
# File 'lib/dir_model/import.rb', line 5

def source_path
  @source_path
end

Instance Method Details

#initialize(path, options = {}) ⇒ Object



7
8
9
10
11
12
13
# File 'lib/dir_model/import.rb', line 7

def initialize(path, options={})
  super # set parent
  @source_path, @context = path, OpenStruct.new(options[:context])
  @index, @previous      = options[:index], options[:previous].try(:dup)
  @load_state            = :ghost
  @foreign_value         = options[:foreign_value]
end

#skip?Boolean

Returns:

  • (Boolean)


15
16
17
18
# File 'lib/dir_model/import.rb', line 15

def skip?
  load
  !@_match
end