Module: SetAttributes::DataSource

Included in:
Controls::DataSource::Example, Hash, Object
Defined in:
lib/set_attributes/data_source.rb,
lib/set_attributes/data_source/hash.rb,
lib/set_attributes/data_source/object.rb

Defined Under Namespace

Modules: Build Classes: Hash, Object

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#sourceObject (readonly)

Returns the value of attribute source.



9
10
11
# File 'lib/set_attributes/data_source.rb', line 9

def source
  @source
end

Class Method Details

.build_data_source(source) ⇒ Object



21
22
23
24
# File 'lib/set_attributes/data_source.rb', line 21

def self.build_data_source(source)
  data_source_class = implementation(source)
  data_source_class.build(source)
end

.implementation(source) ⇒ Object



26
27
28
29
30
31
32
# File 'lib/set_attributes/data_source.rb', line 26

def self.implementation(source)
  if source.is_a?(::Hash)
    return DataSource::Hash
  else
    return DataSource::Object
  end
end

.included(cls) ⇒ Object



3
4
5
6
7
# File 'lib/set_attributes/data_source.rb', line 3

def self.included(cls)
  cls.class_exec do
    extend Build
  end
end

Instance Method Details

#initialize(source) ⇒ Object



11
12
13
# File 'lib/set_attributes/data_source.rb', line 11

def initialize(source)
  @source = source
end