Skip to content
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

Unable to represent properties from hash since grape v0.12.0 #14

Open
RinkeRiezebos opened this issue Jul 1, 2015 · 4 comments
Open
Labels

Comments

@RinkeRiezebos
Copy link

Hi there,

In advance: Please let me know if this is the wrong place to report this issue, it might be better to report at the representable gem or grape gem.

The issue: Since the update of the grape gem from v0.11.0 (still works) to v0.12.0 (doesn't work) I am unable to represent values from a hash using Grape-Roar, eg:

Gems:

  • roar (1.0.1)
  • grape (0.11.0)
  • grape-entity (0.4.5)
  • grape-roar (0.3.0)
module API
    module V1
        module Representers
            module SomeRepresenter 
                include Roar::JSON
                include Roar::Hypermedia
                include Grape::Roar::Representer

                property :some_property
            end
        end
    end
end

Throws:

> undefined method `some_property' for #<Hash:0x007f9f5b281318>

representable (2.2.3) lib/representable/binding.rb, line 98
-----------------------------------------------------------

ruby
   93         evaluate_option(:parse_filter, value, doc) { value }
   94       end
   95   
   96       def get
   97         evaluate_option(:getter) do
>  98           exec_context.send(getter)
   99         end
  100       end
  101   
  102       def set(value)
  103         evaluate_option(:setter, value) do


App backtrace
-------------

Full backtrace
--------------

 - representable (2.2.3) lib/representable/binding.rb:98:in `block in get'
 - representable (2.2.3) lib/representable/binding.rb:120:in `evaluate_option'
 - representable (2.2.3) lib/representable/binding.rb:97:in `get'
 - representable (2.2.3) lib/representable/binding.rb:56:in `block in compile_fragment'
 - representable (2.2.3) lib/representable/binding.rb:120:in `evaluate_option'
 - representable (2.2.3) lib/representable/binding.rb:55:in `compile_fragment'
 - representable (2.2.3) lib/representable/mapper.rb:73:in `compile_fragment'
 - representable (2.2.3) lib/representable/mapper.rb:33:in `serialize_property'
 - representable (2.2.3) lib/representable/mapper.rb:25:in `block in serialize'
 - representable (2.2.3) lib/representable/mapper.rb:24:in `serialize'
 - representable (2.2.3) lib/representable.rb:48:in `create_representation_with'
 - representable (2.2.3) lib/representable/hash.rb:35:in `to_hash'
 - representable (2.2.3) lib/representable/json.rb:35:in `to_json'
 - grape-roar (0.3.0) lib/grape/roar/formatter.rb:6:in `call'
 - grape (0.12.0) lib/grape/middleware/formatter.rb:34:in `block in after'
 - grape (0.12.0) lib/grape/middleware/formatter.rb:33:in `after'
 - grape (0.12.0) lib/grape/middleware/base.rb:25:in `call!'
 - grape (0.12.0) lib/grape/middleware/base.rb:18:in `call'
 - grape (0.12.0) lib/grape/middleware/base.rb:24:in `call!'
 - grape (0.12.0) lib/grape/middleware/base.rb:18:in `call'
 - grape (0.12.0) lib/grape/middleware/error.rb:27:in `block in call!'
 - grape (0.12.0) lib/grape/middleware/error.rb:26:in `call!'
 - grape (0.12.0) lib/grape/middleware/base.rb:18:in `call'
 - rack (1.6.4) lib/rack/head.rb:13:in `call'
 - rack (1.6.4) lib/rack/builder.rb:153:in `call'
 - grape (0.12.0) lib/grape/endpoint.rb:196:in `call!'
 - grape (0.12.0) lib/grape/endpoint.rb:184:in `call'
 - rack-mount (0.8.3) lib/rack/mount/route_set.rb:152:in `block in call'
 - rack-mount (0.8.3) lib/rack/mount/code_generation.rb:96:in `block in recognize'
 - rack-mount (0.8.3) lib/rack/mount/code_generation.rb:68:in `optimized_each'
 - rack-mount (0.8.3) lib/rack/mount/code_generation.rb:95:in `recognize'
 - rack-mount (0.8.3) lib/rack/mount/route_set.rb:141:in `call'
 - grape (0.12.0) lib/grape/api.rb:98:in `call'
 - grape (0.12.0) lib/grape/api.rb:33:in `call!'
 - grape (0.12.0) lib/grape/api.rb:29:in `call'
 - actionpack (4.2.0) lib/action_dispatch/routing/mapper.rb:51:in `serve'
 - actionpack (4.2.0) lib/action_dispatch/journey/router.rb:43:in `block in serve'
 - actionpack (4.2.0) lib/action_dispatch/journey/router.rb:30:in `serve'
 - actionpack (4.2.0) lib/action_dispatch/routing/route_set.rb:802:in `call'
 - omniauth (1.2.2) lib/omniauth/strategy.rb:186:in `call!'
 - omniauth (1.2.2) lib/omniauth/strategy.rb:164:in `call'
 - omniauth (1.2.2) lib/omniauth/strategy.rb:186:in `call!'
 - omniauth (1.2.2) lib/omniauth/strategy.rb:164:in `call'
 - omniauth (1.2.2) lib/omniauth/strategy.rb:186:in `call!'
 - omniauth (1.2.2) lib/omniauth/strategy.rb:164:in `call'
 - omniauth (1.2.2) lib/omniauth/strategy.rb:186:in `call!'
 - omniauth (1.2.2) lib/omniauth/strategy.rb:164:in `call'
 - omniauth (1.2.2) lib/omniauth/strategy.rb:186:in `call!'
 - omniauth (1.2.2) lib/omniauth/strategy.rb:164:in `call'
 - omniauth (1.2.2) lib/omniauth/strategy.rb:186:in `call!'
 - omniauth (1.2.2) lib/omniauth/strategy.rb:164:in `call'
 - warden (1.2.3) lib/warden/manager.rb:35:in `block in call'
 - warden (1.2.3) lib/warden/manager.rb:34:in `call'
 - rack-cors (0.4.0) lib/rack/cors.rb:80:in `call'
 - rack (1.6.4) lib/rack/etag.rb:24:in `call'
 - rack (1.6.4) lib/rack/conditionalget.rb:25:in `call'
 - rack (1.6.4) lib/rack/head.rb:13:in `call'
 - actionpack (4.2.0) lib/action_dispatch/middleware/params_parser.rb:27:in `call'
 - actionpack (4.2.0) lib/action_dispatch/middleware/flash.rb:260:in `call'
 - rack (1.6.4) lib/rack/session/abstract/id.rb:225:in `context'
 - rack (1.6.4) lib/rack/session/abstract/id.rb:220:in `call'
 - actionpack (4.2.0) lib/action_dispatch/middleware/cookies.rb:560:in `call'
 - activerecord (4.2.0) lib/active_record/query_cache.rb:36:in `call'
 - activerecord (4.2.0) lib/active_record/connection_adapters/abstract/connection_pool.rb:647:in `call'
 - activerecord (4.2.0) lib/active_record/migration.rb:378:in `call'
 - actionpack (4.2.0) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
 - activesupport (4.2.0) lib/active_support/callbacks.rb:88:in `_run_callbacks'
 - activesupport (4.2.0) lib/active_support/callbacks.rb:734:in `_run_call_callbacks'
 - activesupport (4.2.0) lib/active_support/callbacks.rb:81:in `run_callbacks'
 - actionpack (4.2.0) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
 - actionpack (4.2.0) lib/action_dispatch/middleware/reloader.rb:73:in `call'
 - actionpack (4.2.0) lib/action_dispatch/middleware/remote_ip.rb:78:in `call'
 - better_errors (2.1.1) lib/better_errors/middleware.rb:84:in `protected_app_call'
 - better_errors (2.1.1) lib/better_errors/middleware.rb:79:in `better_errors_call'
 - better_errors (2.1.1) lib/better_errors/middleware.rb:57:in `call'
 - actionpack (4.2.0) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
 - web-console (2.1.3) lib/web_console/middleware.rb:37:in `call'
 - actionpack (4.2.0) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
 - railties (4.2.0) lib/rails/rack/logger.rb:38:in `call_app'
 - railties (4.2.0) lib/rails/rack/logger.rb:20:in `block in call'
 - activesupport (4.2.0) lib/active_support/tagged_logging.rb:68:in `block in tagged'
 - activesupport (4.2.0) lib/active_support/tagged_logging.rb:26:in `tagged'
 - activesupport (4.2.0) lib/active_support/tagged_logging.rb:68:in `tagged'
 - railties (4.2.0) lib/rails/rack/logger.rb:20:in `call'
 - actionpack (4.2.0) lib/action_dispatch/middleware/request_id.rb:21:in `call'
 - rack (1.6.4) lib/rack/methodoverride.rb:22:in `call'
 - rack (1.6.4) lib/rack/runtime.rb:18:in `call'
 - activesupport (4.2.0) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
 - rack (1.6.4) lib/rack/lock.rb:17:in `call'
 - actionpack (4.2.0) lib/action_dispatch/middleware/static.rb:113:in `call'
 - rack (1.6.4) lib/rack/sendfile.rb:113:in `call'
 - utf8-cleaner (0.0.9) lib/utf8-cleaner/middleware.rb:18:in `call'
 - railties (4.2.0) lib/rails/engine.rb:518:in `call'
 - railties (4.2.0) lib/rails/application.rb:164:in `call'
 - thin (1.6.3) lib/thin/connection.rb:86:in `block in pre_process'
 - thin (1.6.3) lib/thin/connection.rb:84:in `pre_process'
 - thin (1.6.3) lib/thin/connection.rb:53:in `process'
 - thin (1.6.3) lib/thin/connection.rb:39:in `receive_data'
 - eventmachine (1.0.7) lib/eventmachine.rb:187:in `run'
 - thin (1.6.3) lib/thin/backends/base.rb:73:in `start'
 - thin (1.6.3) lib/thin/server.rb:162:in `start'
 - thin (1.6.3) lib/thin/controllers/controller.rb:87:in `start'
 - thin (1.6.3) lib/thin/runner.rb:200:in `run_command'
 - thin (1.6.3) lib/thin/runner.rb:156:in `run!'
 - thin (1.6.3) bin/thin:6:in `<top (required)>'
@dblock
Copy link
Member

dblock commented Jul 1, 2015

Since it's clearly a regression via Grape this is a good place to report it. Do you think you can build a test in grape-roar that reproduces this?

@dblock dblock added the bug? label Jul 1, 2015
@RinkeRiezebos
Copy link
Author

I can try - but have no experience yet w/ tests and have not too much free time at the moment either, but I will see what I can do ;)

@dblock
Copy link
Member

dblock commented Jul 3, 2015

What am I paying you for?! :)

@dblock
Copy link
Member

dblock commented Feb 17, 2017

Did you ever figure this out @RinkeRiezebos?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants