Class: Keepcon::Entity

Inherits:
Object
  • Object
show all
Includes:
ActionView::Helpers::TagHelper
Defined in:
lib/keepcon/entity.rb,
lib/keepcon/entity/response.rb

Defined Under Namespace

Classes: Response

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) ⇒ Entity

Returns a new instance of Entity.



12
13
14
# File 'lib/keepcon/entity.rb', line 12

def initialize(params = {})
  params.each { |k, v| send("#{k}=", v) }
end

Instance Attribute Details

#contextObject

Returns the value of attribute context.



10
11
12
# File 'lib/keepcon/entity.rb', line 10

def context
  @context
end

#instanceObject

Returns the value of attribute instance.



10
11
12
# File 'lib/keepcon/entity.rb', line 10

def instance
  @instance
end

Instance Method Details

#send_data(mode) ⇒ Object



27
28
29
# File 'lib/keepcon/entity.rb', line 27

def send_data(mode)
  parse_response(context.client.content_request(to_xml, mode))
end

#to_xmlObject



23
24
25
# File 'lib/keepcon/entity.rb', line 23

def to_xml
  Gyoku.xml(xml_hash)
end

#translateObject



16
17
18
19
20
21
# File 'lib/keepcon/entity.rb', line 16

def translate
  translation = context.attribute_names.map do |attr_name|
    [context.translate(attr_name), instance.send(attr_name)]
  end
  Hash[translation]
end