Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
thrivesmart-xml_protected
Advanced tools
h1. XmlProtected
Keeps specified attributes of a model out of to_xml, by aliasing to_xml, and automatically sending in the correct :excludes
to the original to_xml
method, e.g. :excludes => [:attr1, :attr2, ...]
NOTE: as of this time, it doesn't protect these attributes from reading. For that, use this in conjunction with :attr_protected
h2. Usage
An ActiveRecord Model:
class Model < ActiveRecord::Base include XmlProtected # Required because it's a gemmefied plugin xml_protected :attr1, :attr2, :attr3 end
You can also access these attributes from the added class method:
protected_xml_attributes
h3. In Conjunction with attr_protected
class Model < ActiveRecord::Base include XmlProtected # Required because it's a gemmefied plugin attr_protected :attr1, :attr2, :attr3 xml_protected :attr1, :attr2, :attr3 end
h2. Installation
To enable the library your Rails 2.1 (or greater) project, use the gem configuration method in "config/environment.rb
"
Rails::Initializer.run do |config| config.gem 'thrivesmart-xml_protected', :lib => 'xml_protected', :source => 'http://gems.github.com' end
The :lib
is important, because rails gets confused when the name of the gem is different from the library.
And of course, run
rake gems:install
To get them installed on your system.
Optionally, to unpack it into your application, just run:
rake gems:unpack GEM=thrivesmart-xml_protected
h2. How it works
Two methods are extended onto your active record class:
xml_protected(*attributes)
protected_xml_attributes
Adds to the inheritable attribute "xml_protected_attrs" the attributes that are speicified in this call. If this is the first time the method is called, it also aliases the old to_xml, and specified a new one which reads from these xml_protected_attrs
Simply returns the values currently in "xml_protected_attrs".
One method is included into your active record class, which is pretty self explanatory:
def to_xml(options = {}) options[:except] ||= [] xml_protected_to_xml(options.merge(:except => options[:except].concat(self.class.protected_xml_attributes))) end
h2. Copyright & License
Copyright (c) 2008 ThriveSmart, LLC, released under the MIT license
FAQs
Unknown package
We found that thrivesmart-xml_protected demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.