Module: CrystalApi
- Defined in:
- lib/crystal_api.rb,
lib/crystal_api/url.rb,
lib/crystal_api/money.rb,
lib/crystal_api/photo.rb,
lib/crystal_api/store.rb,
lib/crystal_api/errors.rb,
lib/crystal_api/report.rb,
lib/crystal_api/product.rb,
lib/crystal_api/variant.rb,
lib/crystal_api/version.rb,
lib/crystal_api/webhook.rb,
lib/crystal_api/category.rb,
lib/crystal_api/attributes.rb,
lib/crystal_api/descriptor.rb,
lib/crystal_api/store_prefs.rb,
lib/crystal_api/market_prices.rb,
lib/crystal_api/error_response.rb,
lib/crystal_api/store_endpoint.rb,
lib/crystal_api/message_verifier.rb,
lib/crystal_api/webhook_envelope.rb,
lib/crystal_api/webhook_verifier.rb,
lib/crystal_api/product_descriptor.rb,
lib/crystal_api/variant_descriptor.rb,
lib/crystal_api/hmac_request_signing.rb,
lib/crystal_api/paginated_collection.rb,
lib/crystal_api/webhook_registration.rb,
lib/crystal_api/received_webhook_parser.rb
Defined Under Namespace
Modules: Attributes, HmacRequestSigning
Classes: CannotParseJson, Category, Descriptor, Error, ErrorResponse, MarketPrices, MessageVerifier, Money, PaginatedCollection, Photo, Product, ProductDescriptor, ReceivedWebhookParser, Report, Store, StoreEndpoint, StorePrefs, Url, Variant, VariantDescriptor, Webhook, WebhookEnvelope, WebhookRegistration, WebhookVerifier
Constant Summary
collapse
- VERSION =
"0.1.0"
Class Method Summary
collapse
Class Method Details
.find_klass(word) ⇒ Object
15
16
17
18
19
20
21
22
23
|
# File 'lib/crystal_api.rb', line 15
def self.find_klass(word)
camel_cased_word = ActiveSupport::Inflector.camelize(word)
if CrystalApi.const_defined?("#{camel_cased_word}")
CrystalApi.const_get(camel_cased_word)
else
raise CrystalApi::CannotParseJson.new("No objects to parse #{word}!")
end
end
|
.from_json(object) ⇒ Object
11
12
13
|
# File 'lib/crystal_api.rb', line 11
def self.from_json(object)
find_klass(object.keys.first).from_json(object)
end
|