So I have a module which have used the name "log" for one of its internal methods.
The problem is, that this module has an "extend self" line. If I call this module in a script as well as load the rails environment, everytime the keyword "log" is used (i.e Rails.application.config.paths.log, or config.paths.log) the method inside that module is getting invoked instead of what the original file was looking for.
Is there a way to do a MyModule.module_eval and somehow rename the method name and route all the local calls inside that module that called "log" into the new method?
Otherwise Rails and this module don't play nice together.
Any help would be appreciated!
Found an answer. I privatized the bad method inside the module using module_eval
NoSoSmartModule.module_eval do
private :log
end
Related
I have a macro that is used in my company that creates something called Requests
Dim request As New Requests
I am creating a new macro with the same standard; however, I can't seem to get it to work. I always get the error below when I attempt to run it.
The following are the References that I have selected.
The reason selecting all the references isn't working is because Requests is user defined. So there is a missing module, class module or the type hasn't been declared. More code would help determine the issue specifically.
I am working with ArcGIS 10.5, installed on-premise, and are developing our feature class in .NET.
I have an issue with registering feature classes. We have created a Feature Class and registered the DLL through “ESRIRegAsm.exe”, and it appears in ArcCatalog:
Trigger appearing image
But when I try to create the Feature Class, I get the following error:
Failed to create feature class. Unable to create object class extension COM Component
Which isn't very helpful, unfortunately.
The odd thing is, that we have another trigger registered on another Feature Class, that works as expected. And the new trigger is based on a copy of the old trigger's code (with changed GUID's).
The steps I have done so far:
I have tried to add the feature class to the component category using categories.exe.
Registered it using ESRIRegAsm.exe for both Desktop and Engine.
Checked that there are .ecfg config files - and there are.
Checked that the CLSID's appear in the windows registry.
The essential parts of our trigger source-code can be found here: here.
Any help would be greatly appreciated, as we are stuck on this.
Our issue was that our ID's were wrong in the code.
The ClassExtensionCLSID should return the same ID as TriggerExtension has.
Moreover, InstanceCLSID should always return 52353152-891A-11D0-BEC6-00805F7C4268, and should hence not get a new ID.
whenever user install or upgrade any module I need to perform particular action based on that.
I looked into module.py for methods button_install, button_upgrade etc and tried to override it but models for specific modules are not created yet. Plus if i am installing module via terminal button_upgrade and button_install doesn't get called.
Which method should i use to perform above activity?
Regards,
If you want to run some code for any module install/upgrade, create a module that has a model that inherits from ir.module.module and override the button_install and button_upgrade methods.
If you want to run some code for a specific module there are two options:
In one of your models override init (not init) or weird stuff will happen. Have a look at account_analytic_entries_report.py in core account module for an example.
Create a my_module_config.xml file, add in a entry like this:
<function model="my.model.name" name="do_stuff" />
I have a big ZF2 project using a lot of modules.
We need to find a way to automatically PREPEND an Optional custom route to every existing route in all modules, using code from only One module.
And it needs to work with the Url view helper.
In every module I have the default route which is basically :
/ModuleName[/:controller[/:action]]
But my new module (Company) needs to add a Company context to every route like so :
[/company/:company_id] /ModuleName[/:controller[/:action]]
As you may have understood, the /company/id part is Optional, and I need a default company_id.
I do not want to add this route in every module's config file.
I tried adding a route in the Company module's config file, but I quickly understood that we cannot define the MODULE parameter inside the route definition, since Zend2 uses namespaces instead.
Also, we will need to do the same thing for langs.
At the end, we will need something like this :
[/:lang][/company/:company_id]/ModuleName[/:controller[/:action]]
Without changing the current config files in any other existing module.
Anyone has The solution for this ?
thank you !
I have solved my problem, and will share it here if anyone needs it.
I will only explain the big idea without posting any line of code since it strongly depends on the way you built your project, and also, it is better to implement it your own way to understand it better, cause if you copy-paste it without trying to understand it WILL break your whole project.
That said, if you cannot understand this explanation, you cannot implement this anyways.
First of all, I have a BaseModule that every module class extends from, and this BaseModule implements the getConfig() method itself automatically and it is final so no module can override it.
If your project is not built like that it will NOT work and you can stop right here.
In this BaseModule I have a STATIC method called prependRouteSegment(), which basically adds key=>array to a PRIVATE STATIC array variable.
In my case, the key is the route and the array is the default params for this route.
Then, in the getConfig() method, after fetching the config file and before returning it as the config array, I can edit anything I want.
So basically I edit all the existing 'Segment' routes and concatenate my routes from the static variable and the original one, then I add my default params.
But there is one more thing that is very important, you need to actually set the custom routes from each Module BEFORE zend executes every module's getConfig() method.
To do so, first create a STATIC method initCustomRouting() that you can override in any module, then, say my first loaded module is Application, simply parse the list of modules in the __construct() method of your Application module and call this initCustomRouting() statically on each module.
Then, if a certain module needs to prepend a custom route to any existing route, you simply implement in this module the initCustomRouting() method and inside of it you call the prependRouteSegment() static method with your custom route and default params.
That's it !
Dont forget that you cannot use params in a Literal route, and you may not want to prepend something on a hostname route, so in my case I only add the routes to every 'Segment' routes, I simply compare the type when I loop through.
Hope this will help someone !
I am using a package where I want to add an additional option to its main function and change the content in the main function accordingly. Other than that, I would like to use the package as it is right now.
What is the best way to do this? Any references would be appreciated.
If you think your change is needed by the rest of the world, too:
Contact the maintainer (packageDescription ("pkgName") $ Maintainer),
explain your change and
attach patches for code and documentation to the email?
If only you yourself need the change / want to try around locally:
? fix
see also ? assignInNamespace
get the source (packages on CRAN should be FOSS, but better read the license), make your chagne & install that package locally.
if you need to insert a bit of code (like an extra output statement): ? trace
This is what I did.
Create another function copied from the main function of the given package.
Change the function as you want.
If you need to use internal function of the package (or class), use <package name>::: in front of the function name.
Make your result inherited from the class you want.
For example, class(results) <- c("rpart","nnet")