Class: Isomer::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/isomer/base.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source) ⇒ Base

Returns a new instance of Base.



20
21
22
# File 'lib/isomer/base.rb', line 20

def initialize(source)
  @source = source
end

Instance Attribute Details

#baseObject (readonly)

Returns the value of attribute base.



2
3
4
# File 'lib/isomer/base.rb', line 2

def base
  @base
end

#sourceObject (readonly)

Returns the value of attribute source.



2
3
4
# File 'lib/isomer/base.rb', line 2

def source
  @source
end

Class Method Details

.from(source_type, options = {}) ⇒ Object



4
5
6
7
8
9
# File 'lib/isomer/base.rb', line 4

def self.from(source_type, options = {})
  source = Isomer::Sources.factory(source_type, @parameters, options)
  source.load_and_validate

  new(source)
end

.parameter(id, options = {}) ⇒ Object



11
12
13
14
15
16
17
18
# File 'lib/isomer/base.rb', line 11

def self.parameter(id, options = {})
  parameter = Isomer::Parameter.new(id, options)
  (@parameters ||= []) << parameter

  define_method(id) do
    source.for(parameter)
  end
end