Displaying 20 results from an estimated 57 matches for "someclass".
2006 Mar 04
2
convert string to AR class
Hi everyone,
I''m trying to convert a string passed on the command-line into an
ActiveRecord class, so I can do something like this.
a="SomeClass"
a.find(:all)
where
class SomeClass < ActiveRecord::Base
end
This appears to work (better ways would be appreciated):
a="SomeClass"
b=eval a
b.find(:all)
However I would like to make sure this is an real class first, so I
tried this since class names...
2006 Sep 27
1
acts_as_taggable with single-table inheritance?
Does anyone have any experience making this work? I installed the
plugin and tried the following:
class SomeClass < ActiveRecord::Base
acts_as_Taggable
end
class SubClass1 < SomeClass
end
class SubClass2 < SomeClass
end
SubClass1.tag_with("tag")
and notice that taggable_type = SomeClass
when I do SubClass2.find_tagged_with("tag") a SubClass1 object is
returned.
Any help w...
2014 Feb 11
2
$new cannot be accessed when running from Rscript and methods package is not loaded
Hi
Accesses the $new method for a class defined in a package fails if the
methods package is not loaded. I have created a test package with the
following single code file:
newTest <- function() {
cl <- get("someClass")
cl$new
}
someClass <- setRefClass("someClass")
(This is similar to code actually used in the testthat package.)
If methods is not loaded, executing the newTest function fails in the
following scenarios:
- Package "depends" on methods (scenario "depend"...
2007 Jul 25
2
initalizing and checking validity of S4 classes
...RY=Polish_Poland.1250;LC_NUMERIC=C;LC_TIME=Polish_Poland.1250
attached base packages:
[1] "stats" "graphics" "grDevices" "utils" "datasets" "methods"
[7] "base"
>
-b-e-g-i-n--r--c-o-d-e-
setClass( "someclass", representation(v="numeric", l="character"),
prototype( v=numeric(0),
l=character(0) )
)
setMethod("initialize", "someclass",
function(.Object, v=numeric(0), l=character(0))
{
# strip the vector names
cv <- v
cl <- l
name...
2010 Apr 21
1
VERY basic question about S4 classes
...I defined a class with two methods (myMethod1 and myMethod2). I want to call myMethod1 within myMethod2. Why does the code below not work? The name 'myMethod1' doesn't appear to have meaning inside myMethod2, even though the two methods belong to the same class.
setClass(Class="SomeClass",
representation=representation(
amount="numeric")
)
setGeneric (name="myMethod1",
def=function(object){standardGeneric("myMethod1")}
)
setMethod(f = "myMethod1",
signature = "SomeClass",
definition=function(object) {print(object...
2005 Aug 10
1
using modules with models?
...t don''t map to the
database, and I''d like to put some of these in seperate modules. I''ve
been wrestling with this for 2 days and can''t figure out how to get it
to work. Rails seems to handle it fine for controllers, though.
I tried creating a class SomeModule::SomeClass. I have a file named
''some_class.rb'' in app/models/some_module. I keep getting this:
/usr/lib/ruby/gems/1.8/gems/activesupport-1.1.1/lib/active_support/dependencies.rb:186:in
`const_missing'': uninitialized constant SomeClass (NameError)
So, I tried creating a file cal...
2013 Apr 16
7
puppet-cleaner: makes puppet DSL code comply with a subset of the style guide
...SL code to puppet 2.7 style guide and expectations. I''m
uploading it to github today for anyone to use.
https://github.com/santana/puppet-cleaner
Externally, you run puppet-clean file.pp and it can transform this:
/*
multiline comment
trailing white space here ->
*/
class someclass($version = "5", $platform = "rhel6")
{
if ! ($version in ["4", "5"] or !($platform in ["rhel5", "rhel6"])) {
fail("Version $version on $platform is not supported")
}
else {
notice("Defining class for version...
2005 Mar 03
0
Scaffold in 0.10
Hi.
I''ve done following things:
>./scripts/generate model Someclass
added self.table_name in someclass.rb with my custom tablename
>./scripts/generate scaffold someclass
And it logs out following : ''mybase_dev.someclasses'' doesn''t exist: SHOW
FIELDS FROM someclasses ...
It seems generator just ignores my table name definition...
I...
2010 Apr 25
1
method dispatching vs inheritance/polymorphism (re-post)
...ned by setGeneric vis-a-vis
methods defined by inheritance and polymorphism. setGeneric offers a 'clean' call to a generic function, ie. no need to call new(), so less typing to do for the user. But such explicit calls can also be avoided by functions like f <- function(x, y) new(Class = SomeClass, x=x, y=y). Then again, R relies heavily on method dispatching, so it must have clear advantages.
*confused* Can anybody enlighten me? Thanks in advance!
Cheers!!
Albert-Jan
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
All right, but apart from the sanitation, the medic...
2009 Nov 02
1
two small wishes (with code sugegstions) for R-core
...large objects in R.
Jens Oehlschl?gel
# Wish no. 1: let [.AsIs return the class AFTER subsetting, not the class of the original object
# Wish no. 2: adjust write.csv and write.csv2 for multiple calls in chunked writing
# Rationale no. 1: a couple of packages will return a different class than SomeClass when subsetting with [.SomeClass
# and still need to keep the AsIs property
# Examples for classes returning different classes on subscipting are in packages 'bit', 'ff', 'bigmemory'
# For classes where [.SomeClass will return class SomeClass, such a change will not hurt
#...
2006 May 09
2
name and class href attribute in a link_to_remote
I have a link to remote and I''m trying to get the name="" and the
class="" attribute in the href so the link will come out like this:
<a href="action" onclick"ajax(action)" name="Title Of Link"
class="someclass">
So far the link looks like this:
<% for course in @courses %>
<%= link_to_remote "#{course.title}",
{:url => {:action => "add_to_cart", :id => course},
:complete => visual_effect(:highlight, "schedule", :duration =>
1.5)},...
2011 Sep 06
1
list of all methods winthin an S4 class
Hello,
How can I generate an overview/vector of all the methods winthin an S4 class? Similar to dir() in this Python code:
>>> class SomeClass():
def some_method_1(self):
pass
def some_method_2(self):
pass
>>> dir(SomeClass)
['__doc__', '__module__', 'some_method_1', 'some_method_2']
>>>
Thanks in advance!
Cheers!!
Albert-Jan
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~...
2010 Jul 21
1
fix()ing an S4 method
...something similar to edit a method of an S4 class. In other words, is there a fix-like function that allows me to edit method definitions without having to go back to the source code?
setGeneric (name="doStuff",def = function(object){standardGeneric("doStuff")})
setClass("SomeClass", representation(text = "character"))
setMethod(f = "doStuff", signature ("SomeClass"), definition = function(object){
return(print(paste("***", object@text))) })
fix(doStuff) # Does NOT give the intended result. How can I make R show the method def...
2007 Jul 24
2
Dealing with nested/namespaced classes w/ describe
Hi all,
Just wondering about this: I''ve been dealing with classes/modules
nested in several layers of namespaces. Here would be an example of
a describe block:
describe ClassOne::ClassTwo::ClassThree, "description here" do
...
end
What would be the easiest way to write something a little more terse,
like:
describe ClassThree, "description here" do
...
end
2006 Nov 22
2
.class call to the mock object (or any existing methods)
...ectation. Is
there any better way of doing it?
object = mock()
....
klass = class <<object; self; end
klass.send(:undef_method, "class") # I had to do this because Mocha
utilizes "method_missing(symbol, *arguments, &block) " method.
object.expects(:class).returns(SomeClass)
...
And thanks for such a nice library.
------------------------------
Kurman Karabukaev
Application Developer
ThoughtWorks Inc.
(312) 282 0231
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/mocha-developer/attachments/20061122/fa...
2007 Sep 18
2
Making attachment_fu polymorphic
...comes with no warranty,
## expressed or implied.
#############################################################################################
@@attachment_config = []
@@validates_as_attachment = nil
# adds methods to the class that is mixing the module in
def self.append_features(someClass)
@@klass = someClass
def someClass.has_polymorphic_attachment(config)
@@attachment_config = config
end
def someClass.validates_as_polymorphic_attachment
@@validates_as_attachment = true
end
super
end
# may only work for macs. If this is giving you tr...
2019 Nov 12
0
class(<matrix>) |--> c("matrix", "arrary") [was "head.matrix ..."]
...t; Thank you, Duncan.
> That's definitely a strong reason for inherits(), because often
> in such code, you don't know in advance what objects will be
> passed to your function.
>
>
> On Twitter, others have asked "the same", arguing that
>
> "<someclass>" %in% class(.)
>
>> uses usual syntax, and thus looks less intimidating than
>> inherit() and less cryptic than is()
%-/ (<- ASCII version of the rolling eyes emoji)
<ranting mode>
The most cryptic of the 3 forms being by far:
"<someclass>&quo...
2019 Nov 11
2
class(<matrix>) |--> c("matrix", "arrary") [was "head.matrix ..."]
...t involving S4.
> Duncan Murdoch
Thank you, Duncan.
That's definitely a strong reason for inherits(), because often
in such code, you don't know in advance what objects will be
passed to your function.
On Twitter, others have asked "the same", arguing that
"<someclass>" %in% class(.)
> uses usual syntax, and thus looks less intimidating than
> inherit() and less cryptic than is()
I think you should all use -- and *teach* --
inherits(.) more often, and it would no longer be intimidating.
Also, for the speed fetishists: inherits() will typicall...
2006 Nov 19
2
underscores, sugar, and more and more bugs
...enefits including:
# more clarity in the API
# a place to put meaningful rdoc
# a potential formal plugin point
2. Change should_be to ONLY handle arbitrary predicates (not serve as
an alias for should_equal):
subject.should_be :empty => passes if subject.empty?
subject.should_be :instance_of, SomeClass => passes if
subject.instance_of? SomeClass
etc...
In my opinion (feel free to disagree), this actually makes these
examples more readable. Consider these two:
@bdd_framework.should_be_adopted_quickly #current
@bdd_framework.should_be :adopted_quickly #proposed
In my view, these read equally...
2006 Feb 14
1
Error handling
Hi,
I''m stuck right now with a problem concerning error handling. I''ll try to
explain the problem in short:
In a controller class I have a method edit:
def edit
@some_class = SomeClass.find(params[:id])
end
The record originates from a database table. What happens if the user enters
a field that fails validation and I return to my edit page? I get the idea
that th original value from the database gets reloaded all the time, but I
want to see the value the user entered.
I try...