similar to: Extending instance-methods of an Module for Plugin-Development

Displaying 20 results from an estimated 2000 matches similar to: "Extending instance-methods of an Module for Plugin-Development"

2006 Sep 04
2
"include" versus "extend" - what's the difference
Hi, Just wondering when one would use "include" over "extend"? Both seem to bring in methods to the class no? The context is I''m just trying to understand why both are used with the acts_as_audited plugin: Full extract from plugin (used within here): ================================================== # Copyright (c) 2006 Brandon Keepers # # Permission is hereby
2006 May 11
1
acts_as_paranoid and nested scopes in Rails 1.1
I have a real problem with the acts_as_paranoid plugin. The find-scope nesting does not seem to work at all. The description: I made a copy of ''acts_as_paranoid'' in the plugin directory, renamed it to ''acts_as_very_new''(just nonsense plugin for testing), and just simplified the code: #-------------------------------------------------------------- module
2006 May 11
0
acts_as_paranoid, aliasing and nested scopes in Rails 1.1
I have a real problem with the acts_as_paranoid plugin. The aliasing of find and so the nested scope does not seem to work at all, when combining it with similar plugins. The description: I made a copy of ''acts_as_paranoid'' in the plugin directory, renamed it to ''acts_as_very_new''(just a nonsense plugin for testing), and simplified the code (original code
2013 Aug 29
2
Need a bit help on "module_function" method
The documentation is very straight forward and the mentioned example also cleared all the lines except the one mentioned inside **. http://ruby-doc.org/core-2.0.0/Module.html#method-i-module_function Creates module functions for the named methods. These functions may be called with the module as a receiver, and also become available as instance methods to classes that mix in the module. Module
2007 Nov 27
1
Plugin - How to access object from instance method
Quick question: Given a basic plugin... how can I access an object that I instantiated in the acts_as method from an instance method? Probably some sort of accessor... but where? def self.included(base) base.extend ClassMethods end module ClassMethods def acts_as_test object = Object.new ## This object needs to be accessible from the Instance Methods end include
2006 Mar 12
1
alias_method interferes ApplicationHelper
Hello, I''m using Ruby 1.8.4 (darwinport), rails-1.0.0 (gem) , Powerbook / Mac OS X 10.4.5 , Webrick. How come Rails always raises NoMethodError for my helper (must_fill and rp or number_to_currency_rp) in application_helper.rb ? I doubt that alias_method is the culprit, but if i give # comment then there will be no errors at all ... :/ what am i doing wrong? is it a bug or stupid me? Thx
2007 Apr 23
0
request logging: around_filters can't see error responses!
Hello, I want to emit a structured log entry (in YAML) for every request that hits my Rails app. For example, an entry in this log would look something like: --- SYSTEM_TIME: 0.0166666666666667 USER_TIME: 0.0999999999999996 DB_TIME: 0.00247621536254883 REAL_TIME: 0.091976 STATUS_CODE: 500 SESSION_ID: 64ad46a8841c66bbf64e93335cedc50d REQUEST_ID: 32d6a42f-da58-43e2-ab27-09d3e2a775cb
2006 Mar 12
1
a better way to alias methods
Hi is there a better way to accomplish this task? class PortfolioController < ProjectController layout ''portfolio'' def boing redirect_to :action=>:index end alias_method :new , :boing alias_method :destroy , :boing alias_method :edit , :boing alias_method :update , :boing end My portfolio controller implements view only
2005 Sep 17
0
Reloading and redefining methods: infinite recursion
When I redefine a method like this class Klass alias_method :method_without_addition, :method def method_with_addition ... method_without_addition ... end alias_method :method, :method_with_addition end I get into trouble in the development environment. As these definitions are executed again for each request, the second time around method_without_addition is actually the
2006 Aug 14
0
ActionMailer in an infinite loop? Looks like framework bug.
I would rather post this on the dev list since it looks like only the developers can explain why this is failing. However, I can''t find where you subscribe to it! Any ideas? Here is my problem. Whenever I try to send an email I get a SystemStackError saying stack level too deep. Here is the exception trace:
2008 Jan 18
2
NameError when using alias_method -- but method exists?
Hello Rubyists, I am a bit stumped here. I want to extend the ''load_file'' method in the YAML module. Following along with the PickAxe example of making old methods do new things, I try this in irb: >> module YAML >> alias_method :orig_load_f, :load_file >> def load_file(*args) >> contents = orig_load_f(*args) >>
2007 Feb 26
2
undefined method ... from `alias_method'
0 wicked var/www % ./script/console Loading development environment. >> r = Recipe.find :first NameError: undefined method `recipe_type='' for class `Recipe'' from ./script/../config/../config/../app/models/recipe.rb: 101:in `alias_method'' In recipes_controller: alias_method :orig_recipe_type=, :recipe_type= def recipe_type=(t) if t.nil?
2006 Feb 01
7
Explanation of "alias_method"
Hi! I''m trying to extend ActiveRecord''s find method (Rails 1.0, Ruby 1.8.2), but I recognize a strange behaviour of the "alias_method" call. I wrote a very simple script to explain my problem: ------------------------------------------------------ module ActiveRecordExtension def self.included(base) base.extend(ClassMethods) base.class_eval do
2006 Aug 16
3
AR: column methods?
In a model, it seems that methods for column access are only created when one column method on an object is accessed. So, how can one override the default column methods? For instance: create_table "dogs", :force => true do |t| t.column "color", :string end create_table "tails", :force => true do |t| t.column "dog_id", :integer,
2009 Sep 11
0
Need help with extending a plugin
hey folks I''ve installed the plugin acts_as_taggable_on_steroids (henceforth aatos), and i already have some tagging functionality set up, using the same approach (ie a Tag and a Tagging class with associated tables) as aatos. So, i want my existing Tag and Taggings methods, plus some other methods i have in a module which i include with the taggable classes (ie the ones that would call
2011 Mar 03
1
Does RSpec interfere with Pathname#dirname or Pathname#realpath ?
Hi, I starting a new project, and have run into behavior I cannot replicate in irb, (i.e. outside of using rspec) when the directory? returns true, so I thought I''d ask here, in case any one has seen this badhavior. ruby-1.9.2-p136 rspec (2.5.0) rspec-core (2.5.1) rspec-expectations (2.5.0) rspec-mocks (2.5.0) When I try to run this spec: require Pathname(__FILE__).ascend { |d|
2009 Sep 23
5
Overriding AR read/write_attribute - Overridden write_attribute Is Never Called
Could someone explain this? #config/initializers/ar_attributes.rb module ActiveRecord module AttributeMethods alias_method :ar_read_attribute, :read_attribute def read_attribute(attr_name) p "read_override" ar_read_attribute(attr_name) end alias_method :ar_write_attribute, :write_attribute def write_attribute(attr_name, value)
2006 May 31
1
Help enhancing acts_as_nested_set
I''m trying to enhance acts_as_nested_set. Well actually I already have, but I''ve done a hack up job of it. I would like to contribute these enhancements back, but I need a little help. I''m a complete newbie to this stuff. The only thing I new before coming into this project was vanilla HTML. So over the course of two weeks I''ve picked up Ruby, Rails, MySQL,
2012 Dec 18
2
cache-busting non-digest assets in sprockets in development a good idea? should headers in sprockets be configurable?
Just monkey patched Sprockets in our Rails 3.2.9 app to override the Cache-Control header for html assets that we need to tweak more often in development, but that we don''t want to use digests/fingerprinting with: # Sprockets 2.x patch if Rails.env.development? module Sprockets module Server private alias_method :sprockets_headers, :headers def headers(env,
2006 Sep 20
0
boy, that mongrel_upload_progress handler sucks!
I started actually using the upload progress handler, and noticed it was leaking memory over time. Looking at the code, I noticed that cancelled uploads weren''t being cleaned up. I bugged Zed about adding a request_abort callback to handlers, but I found a simple way to monkey patch that in: # config/mongrel_upload_progress.conf # yes, this file is being used with -S meaning