-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Nazrin::DataAccessor::Struct #25
Conversation
lib/nazrin/searchable/config.rb
Outdated
@@ -1,6 +1,9 @@ | |||
module Nazrin | |||
module Searchable | |||
class Configuration | |||
attr_reader :domain_name | |||
attr_writer :domain_name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
attr_accessor
is preferable.
It makes sense. |
Perhaps we could make it the default data processor if the class doesn't descend from AR::Base or Mongoid::Document, but I like the idea of including Nazrin::Struct as it allows you to load the data from Cloudfront even when using AR or Mongo, if you choose to. |
I understand. |
Please, squash commits, update description. |
@tsuwatch done 😄 |
Thanks @tsuwatch 😄 |
Merged, thank you so much!!! 😆 |
This PR adds a
Struct
data-accessor, if the class that includesNazrin::Searchable
AND defines adomain_name
config, the schema will be read using an AWS-Cloudsearchdescribe_index_fields
call and data will be loaded from Cloudsearch and injected into the constructor when a search is made.Example:
The schema is read and transformed into a mapping which looks like:
If the response looks like:
It will result in a call like:
User.new('id' => '1', 'name' => 'Joan', 'permissions' => ['admin'])