Class: Opera::MobileStore::Developer

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Model, ActiveModel::Serialization, InspectableAttributes, Opera::MobileStoreSDK::APIAccessible, Opera::MobileStoreSDK::IdentityMapable
Defined in:
lib/opera/mobile_store/developer.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Opera::MobileStoreSDK::IdentityMapable

#initialize

Methods included from InspectableAttributes

#inspect

Instance Attribute Details

#address1Object

All attributes are Read-Only…



15
16
17
# File 'lib/opera/mobile_store/developer.rb', line 15

def address1
  @address1
end

#address2Object

All attributes are Read-Only…



15
16
17
# File 'lib/opera/mobile_store/developer.rb', line 15

def address2
  @address2
end

#cityObject

All attributes are Read-Only…



15
16
17
# File 'lib/opera/mobile_store/developer.rb', line 15

def city
  @city
end

#contact_emailObject

All attributes are Read-Only…



15
16
17
# File 'lib/opera/mobile_store/developer.rb', line 15

def contact_email
  @contact_email
end

#country_codeObject

All attributes are Read-Only…



15
16
17
# File 'lib/opera/mobile_store/developer.rb', line 15

def country_code
  @country_code
end

#emailObject

All attributes are Read-Only…



15
16
17
# File 'lib/opera/mobile_store/developer.rb', line 15

def email
  @email
end

#idObject

All attributes are Read-Only…



15
16
17
# File 'lib/opera/mobile_store/developer.rb', line 15

def id
  @id
end

#loginObject

All attributes are Read-Only…



15
16
17
# File 'lib/opera/mobile_store/developer.rb', line 15

def 
  @login
end

#nameObject

All attributes are Read-Only…



15
16
17
# File 'lib/opera/mobile_store/developer.rb', line 15

def name
  @name
end

#orders_emailObject

All attributes are Read-Only…



15
16
17
# File 'lib/opera/mobile_store/developer.rb', line 15

def orders_email
  @orders_email
end

#payment_infoObject

All attributes are Read-Only…



15
16
17
# File 'lib/opera/mobile_store/developer.rb', line 15

def payment_info
  @payment_info
end

#phonesObject

All attributes are Read-Only…



15
16
17
# File 'lib/opera/mobile_store/developer.rb', line 15

def phones
  @phones
end

#stateObject

All attributes are Read-Only…



15
16
17
# File 'lib/opera/mobile_store/developer.rb', line 15

def state
  @state
end

#website_urlObject

All attributes are Read-Only…



15
16
17
# File 'lib/opera/mobile_store/developer.rb', line 15

def website_url
  @website_url
end

#zipObject

All attributes are Read-Only…



15
16
17
# File 'lib/opera/mobile_store/developer.rb', line 15

def zip
  @zip
end

Class Method Details

.build_from_nokogiri_node(node) ⇒ Object



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/opera/mobile_store/developer.rb', line 47

def self.build_from_nokogiri_node(node)
  data = {
    id:            node.xpath("string(@id)").to_i,
    login:         node.xpath("string(@login)").strip,
    email:         node.xpath("string(email)").strip,
    name:          node.xpath("string(name)").strip,
    address1:      node.xpath("string(address1)").strip,
    address2:      node.xpath("string(address2)").strip,
    city:          node.xpath("string(city)").strip,
    state:         node.xpath("string(state)").strip,
    zip:           node.xpath("string(zip)").strip,
    country_code:  node.xpath("string(country_code)").strip,
    website_url:   node.xpath("string(website_url)").strip,
    orders_email:  node.xpath("string(orders_email)").strip,
    contact_email: node.xpath("string(contact_email)").strip,
    phones:        node.xpath("phones").text
  }.select { |key, value| value.present? }

  payment_info = PaymentInfo.build_from_nokogiri_node node.xpath("payment").first
  data[:payment_info] = payment_info if payment_info.present?

  self.new data
end

.deserialize(serializable_hash) ⇒ Object



71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/opera/mobile_store/developer.rb', line 71

def self.deserialize(serializable_hash)
  attributes_hash = serializable_hash.inject({}) do |hsh, keyval|
    field_name, field_value = keyval

    case field_name
    when 'payment_info'
      field_value = PaymentInfo.deserialize field_value
    end

    hsh[field_name] = field_value
    hsh
  end

  self.new attributes_hash
end

Instance Method Details

#attributesObject



20
21
22
23
24
25
26
27
28
29
# File 'lib/opera/mobile_store/developer.rb', line 20

def attributes
  [
    :id, :login, :email, :name, :address1, :address2, :city, :state, :zip,
    :country_code, :website_url, :orders_email, :contact_email, :payment_info
  ].inject({}) do |attributes_hash, field_name|
    field_value = public_send field_name
    attributes_hash[field_name.to_s] = field_value if field_value.present?
    attributes_hash
  end
end

#serializable_hash(options = nil) ⇒ Object

Override of serializable_hash:

This override will prevent dumping special objects to the hash:



34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/opera/mobile_store/developer.rb', line 34

def serializable_hash(options = nil)
  attributes.inject({}) do |shsh, keyval|
    field_name, field_value = keyval

    # Get the payment_info serializable hash:
    field_value = field_value.serializable_hash \
      if field_name == 'payment_info'

    shsh[field_name] = field_value
    shsh
  end
end