rwz / adequate_exposure Goto Github PK
View Code? Open in Web Editor NEWExposing things, adequately
License: MIT License
Exposing things, adequately
License: MIT License
expose :thing, find_by: :slug
should be equivalent to
expose :thing, find: ->(id, scope){ scope.find_by(slug: id) }
expose :current_thing, model: :thing
Should check params[:thing_id]
for params, not params[:current_thing_id]
. Maybe both.
expose :thing, :method_to_get_thing
# equivalent to
expose :thing, ->{ method_to_get_thing }
private
def method_to_get_thing
# get thing
end
i.e
expose :user
expose :reviews, from: :user, decorate: ->{ something }
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 ]
expose :comments, from: :post
should be equivalent to
expose(:comments){ post.comments }
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
expose :thing, scope: :active
should be equivalent to
expose :thing, scope: ->{ Thing.active }
expose :thing, parent: :current_user
should be equivalent to
expose :thing, scope: ->{ current_user.things }
expose(:thing){ some_code_here }
should be equivalent to
expose :thing, ->{ some_code_here }
because parens are ugly in class macros
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.