lib/authlete/model/sns-credentials.rb in authlete-0.3.6 vs lib/authlete/model/sns-credentials.rb in authlete-0.3.7
- old
+ new
@@ -18,11 +18,11 @@
require 'set'
module Authlete
module Model
- class SnsCredentials
+ class SnsCredentials < Authlete::Model::Hashable
# The API key. (String)
attr_accessor :apiKey
alias_method :api_key, :apiKey
alias_method :api_key=, :apiKey=
@@ -31,17 +31,17 @@
alias_method :api_secret, :apiSecret
alias_method :api_secret=, :apiSecret=
# The SNS. (String)
#
- # Valid values are "FACEBOOK".
+ # Currently, the only valid value is "FACEBOOK".
attr_accessor :sns
private
# String attributes.
- STRING_ATTRIBUTES = ::Set.new([:apiKey, :apiSecret, :sns])
+ STRING_ATTRIBUTES = ::Set.new([ :apiKey, :apiSecret, :sns ])
# Mapping from snake cases to camel cases.
SNAKE_TO_CAMEL = {
:api_key => :apiKey,
:api_secret => :apiSecret
@@ -53,44 +53,40 @@
STRING_ATTRIBUTES.each do |attr|
send("#{attr}=", nil)
end
# Set attribute values using the given hash.
- authlete_model_snsCredentials_update(hash)
+ authlete_model_update(hash)
end
- def authlete_model_snsCredentials_to_key(key)
+ def authlete_model_convert_key(key)
key = key.to_sym
# Convert snakecase to camelcase, if necessary.
if SNAKE_TO_CAMEL.has_key?(key)
key = SNAKE_TO_CAMEL[key]
end
- return key
+ key
end
- def authlete_model_snsCredentials_simple_attribute?(key)
+ def authlete_model_simple_attribute?(key)
STRING_ATTRIBUTES.include?(key)
end
- def authlete_model_snsCredentials_update(hash)
- if hash.nil?
- return
- end
+ def authlete_model_update(hash)
+ return if hash.nil?
hash.each do |key, value|
- key = authlete_model_snsCredentials_to_key(key)
+ key = authlete_model_convert_key(key)
- # If the attribute is a simple one.
- if authlete_model_snsCredentials_simple_attribute?(key)
+ if authlete_model_simple_attribute?(key)
send("#{key}=", value)
- next
end
end
- return self
+ self
end
public
# Construct an instance from the given hash.
@@ -100,16 +96,16 @@
def self.parse(hash)
if hash.nil? or (hash.kind_of?(Hash) == false)
return nil
end
- return Authlete::Model::SnsCredentials.new(hash)
+ Authlete::Model::SnsCredentials.new(hash)
end
# Set attribute values using the given hash.
def update(hash)
- authlete_model_snsCredentials_update(hash)
+ authlete_model_update(hash)
end
# Convert this object into a hash.
def to_hash
hash = {}
@@ -119,31 +115,10 @@
val = instance_variable_get(var)
hash[key] = val
end
- return hash
+ hash
end
-
- def [](key)
- key = authlete_model_snsCredentials_to_key(key)
-
- if respond_to?(key)
- return send(key)
- else
- return nil
- end
- end
-
- def []=(key, value)
- key = authlete_model_snsCredentials_to_key(key)
- method = "#{key}="
-
- if respond_to?(method)
- return send(method, value)
- else
- return nil
- end
- end
end
end
-end
+end
\ No newline at end of file