GithubHelp home page GithubHelp logo

adequate_exposure's People

Contributors

chriserin avatar lrgalego avatar plicjo avatar rwz avatar vicramon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

adequate_exposure's Issues

find_by option

expose :thing, find_by: :slug

should be equivalent to

expose :thing, find: ->(id, scope){ scope.find_by(slug: id) }

Shortcut to delegate to controller

expose :thing, :method_to_get_thing
# equivalent to
expose :thing, ->{ method_to_get_thing }

private

def method_to_get_thing
  # get thing
end

Support predefines configs

exposure_config :sluggable, find: ->(id, scope){ scope.find_by!(slug: id) }
exposure_config :secure_build, build: ->(scope){ scope.new(secured_params) }

expose :thing, id: :custom_thing_id, with: [ :sluggable, :secure_build ]

Grab build attributes if possible

The default build logic for model should try build on thing_params if it's available. Something similar to this:

def build(scope)
  scope.new(exposure_params)
end

def exposure_params
  exposure_params_method_name = "#{name}_params"
  if controller.responds_to?(exposure_params_method_name)
    controller.send(exposure_params_method_name)
  else
    {}
  end
end

Support scope shortcut

expose :thing, scope: :active

should be equivalent to

expose :thing, scope: ->{ Thing.active }

Support :parent option

expose :thing, parent: :current_user

should be equivalent to

expose :thing, scope: ->{ current_user.things }

Rails 5 Support

I'd like to add support for Rails 5.

How would you want me to go about doing this, without breaking the Rails 4 stuff?

Here's what I did a while back to get adequate_exposure running in Rails 5: plicjo@e1a1b70

I think the above is decent, but not adequate.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.