Module: Taksi::Component::InstanceMethods

Defined in:
lib/taksi/component.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#datasourceObject (readonly)

Returns the value of attribute datasource.



49
50
51
# File 'lib/taksi/component.rb', line 49

def datasource
  @datasource
end

#interface_definitionObject (readonly)

Returns the value of attribute interface_definition.



49
50
51
# File 'lib/taksi/component.rb', line 49

def interface_definition
  @interface_definition
end

#skeletonObject (readonly)

Returns the value of attribute skeleton.



49
50
51
# File 'lib/taksi/component.rb', line 49

def skeleton
  @skeleton
end

Instance Method Details

#content_for(interface) ⇒ Object



63
64
65
66
67
68
69
# File 'lib/taksi/component.rb', line 63

def content_for(interface)
  data = interface.send(datasource)

  skeleton.fields.each_with_object({}) do |field, obj|
    load_data_from_key_to_object(data, field, obj)
  end
end

#idObject



59
60
61
# File 'lib/taksi/component.rb', line 59

def id
  @skeleton.id
end

#initialize(interface_definition, with: nil) ⇒ Object



51
52
53
54
55
56
57
# File 'lib/taksi/component.rb', line 51

def initialize(interface_definition, with: nil)
  @interface_definition = interface_definition
  @datasource = with
  @skeleton = @interface_definition.skeleton.create_component(self.class.identifier,
                                                              &self.class.content_builder)
  super()
end